我目前的设置是8个空格;我该如何重新定义它呢?
当前回答
还有一件事,使用 : retab 将现有制表符转换为空格 http://vim.wikia.com/wiki/Converting_tabs_to_spaces
其他回答
:set sw=4
参见掌握VI编辑器
对于永久的更改,创建文件~/.vim/plugin/tab_expander。用内容进行Vim
set tabstop=4 softtabstop=4 expandtab shiftwidth=4 smarttab
防止碰~/。Vimrc,从而保持其他默认设置不变。
要为当前用户永久地定义此属性,请创建(或编辑).vimrc文件:
$ vim ~/.vimrc
然后,将下面的配置粘贴到文件中。重新启动vim后,将应用选项卡设置。
set tabstop=4 " 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.
set shiftwidth=4 " Indents will have a width of 4
set softtabstop=4 " Sets the number of columns for a TAB
set expandtab " Expand TABs to spaces
或者vim modeline的简写:
vim :set ts=4 sw=4 sts=4 et :
确保vartabstop未设置
set vartabstop=
设置tabstop为4
set tabstop=4