方式一: vim 编辑时设置
:set ts=4 sw=4 sts=4 et
方式二: .vimrc
$ vim ~/.vimrc
#paste the configuration below into the file. Once vim is restarted, the tab settings will apply.
# The width of a TAB is set to 4. Still it is a \t.
# It is just that Vim will interpret it to be having a width of 4.
# size of a hard tabstop
set tabstop=4
# Indents will have a width of 4
set shiftwidth=4
# Sets the number of columns for a TAB. a combination of spaces and tabs are used to simulate tab stops at a width
set softtabstop=4
# Expand TABs to spaces. always uses spaces instead of tab characters
set expandtab
# make "tab" insert indents instead of tabs at the beginning of a line
set smarttab
参考
http://stackoverflow.com/questions/1878974/redefine-tab-as-4-spaces
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/26250550/viewspace-1665380/
,如需转载,请注明出处,否则将追究法律责任。