我正在浏览VimCasts.org archive个视频和number 5封面,使用Vim的自动缩进来格式化源代码。我认为它在我的Objective-C文件中正常工作,但不是我的.vimrc
。
我的标签设置如下:
set tabstop=2
set shiftwidth=2
set softtabstop=2
set expandtab
我的.vimrc
文件包含以下if
块:
if has("autocmd")
filetype on
autocmd BufNewFile,BufRead *.rss,*.atom setfiletype xml
autocmd BufWritePre *.py,*.js :call <SID>StripTrailingWhitespaces()
endif
我认为如果我将光标放在上面的第一行并按下Vjjjj=
,我会得到第二,第三和第四行缩进两个空格,但我得到的是:
if has("autocmd")
filetype on
autocmd BufNewFile,BufRead *.rss,*.atom setfiletype xml
autocmd BufWritePre *.py,*.js :call <SID>StripTrailingWhitespaces()
endif
鉴于Vimscript语言,我的期望是否正确或是否正确?
答案 0 :(得分:3)
您需要将filetype plugin indent on
添加到vimrc以使vim正确进行缩进。 (插件部分不是必需的,但很高兴)
我建议用filetype on
filetype plugin indent on
行