我使用s 13的vim发行版https://github.com/spf13/spf13-vim。我一直试图为.js文件使用2个空格而不是4个空格,因此我在~/.vim/ftplugin中创建了一个js.vim。我做错了吗?
js.vim
set shiftwidth=2 " Use indents of 2 spaces
set tabstop=2 " An indentation every two columns
set softtabstop=2 " Use two spaces while editing发布于 2014-07-05 14:27:02
ftplugin文件名的命名约定是:
{filetype}.vim在您的例子中,文件类型是javascript,而不是js,所以应该是:
~/.vim/ftplugin/javascript.vim或者,更好的:
~/.vim/after/ftplugin/javascript.vim此外,必须使用setlocal而不是set来防止选项泄漏到其他缓冲区:
setlocal shiftwidth=2
setlocal tabstop=2
setlocal softtabstop=2注意,默认的JavaScript ftplugin根本没有定义默认的表宽。
https://stackoverflow.com/questions/24587125
复制相似问题