How to set different tab space widths for different code files (which can be simply judged by the suffix name) in the .vimrc file? For example, the tabs of .rb files are indented by two spaces at a time, the tabs of .c files are indented by three spaces, and the tabs of .cs files are indented by four spaces, similar to this. PS: It only needs to be used on linux and osx. Thanks in advance to all those who provided answers.
ringa_lee2017-05-16 16:43:26
Just set it according to the file type, as follows.
"为不同的文件类型设置不同的空格数替换TAB
autocmd FileType php,python,c,java,perl,shell,bash,vim,ruby,cpp set ai
autocmd FileType php,python,c,java,perl,shell,bash,vim,ruby,cpp set sw=4
autocmd FileType php,python,c,java,perl,shell,bash,vim,ruby,cpp set ts=4
autocmd FileType php,python,c,java,perl,shell,bash,vim,ruby,cpp set sts=4
autocmd FileType javascript,html,css,xml set ai
autocmd FileType javascript,html,css,xml set sw=2
autocmd FileType javascript,html,css,xml set ts=2
autocmd FileType javascript,html,css,xml set sts=2