我有这个标签间距配置:
set autoindent
set smartindent
set expandtab tabstop=4 shiftwidth=4 smarttab softtabstop=4
Run Code Online (Sandbox Code Playgroud)
在配置结束时,我把它:
autocmd FileType javascript,jade,json set shiftwidth=2 tabstop=2 softtabstop=2
Run Code Online (Sandbox Code Playgroud)
2个空格选项卡工作得很好.但是,如果我输入enter(新行),它就变成了4个空格.这是一个例子:
var Post = orm.define('Post', {
title: sequelize.STRING,
content: sequelize.STRING,
| /* wrong spaces */
});
但是如果我使用4个制表符空格,输入后它也会使用4个空格.
我无法弄清楚问题是什么.
它只发生在我在javascript回调函数中编写object-literal时(如上面的代码示例).它适用于通用代码语句和json object-literal.这是一个例子:
/* the 2 spaces works fine*/
app.set('port', 3000);
app.use(express.bodyParser());
/* also works fine here */
var config = {
host: 'localhost',
port: 5432
}
请尝试使用以下内容:
set number
set smartindent
set tabstop=2
set shiftwidth=2
set expandtab
set clipboard=unnamed
Run Code Online (Sandbox Code Playgroud)