vim: 针对不同类型的文件进行不同的缩进 ( vim different indent for different file types)
访问量: 3299
refer to: http://stackoverflow.com/questions/158968/changing-vim-indentation-behavior-by-file-type
最简单的办法:
# ~/.vimrc # 默认显示2格缩进 set shiftwidth=2 set softtabstop=2 set tabstop=2 # 不同的文件显示不同的缩进 autocmd Filetype html setlocal ts=2 sw=2 expandtab autocmd Filetype ruby setlocal ts=2 sw=2 expandtab autocmd Filetype javascript setlocal ts=4 sw=4 sts=0 noexpandtab autocmd Filetype coffeescript setlocal ts=4 sw=4 sts=0 noexpandtab
上面的列子中, html/rb 显示2个缩进, js, coffee则显示4个空格作为缩进