求教根据不同文件类型,自动切换缩紧
比如在 kernel 写代码时,要用 TAB 缩进,但在应用层写 cpp 代码要求 4 个空格缩紧,不会配置,每次切换时 都要手动修改 vimrc 。。。。。
比如在 kernel 写代码时,要用 TAB 缩进,但在应用层写 cpp 代码要求 4 个空格缩紧,不会配置,每次切换时 都要手动修改 vimrc 。。。。。
” general indent setting
set tabstop=4 ” ts
set softtabstop=4 ” sts
set shiftwidth=4 ” sw
set expandtab
set smarttab
” languages specific indent setting
autocmd FileType ruby,html,xml,smarty setlocal ai ts=2 sts=2 sw=2
ai => autoindent
ts => tabstop
sts => softtabstop
sw => shiftwidth
” Tab
filetype indent on
set expandtab ” Always use space instead of tab
autocmd FileType vim setlocal expandtab tabstop=2 shiftwidth=2 softtabstop=2
autocmd FileType sh setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4
autocmd FileType python setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4
autocmd FileType tex setlocal expandtab tabstop=4 shiftwidth=4 softtabstop=4
nathanaelkane/vim-indent-guides 这个插件也不错