我目前的设置是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,从而保持其他默认设置不变。
确保vartabstop未设置
set vartabstop=
设置tabstop为4
set tabstop=4
我基本的~/。Vimrc评论:
set number " show line number
set tabstop=2 " set display width of tab; 1 tab = x space with
set expandtab " transform tab to x space (x is tabstop)
set autoindent " auto indent; new line with number of space at the beginning same as previous
set shiftwidth=2 " number of space append to lines when type >>
将您想要的设置放在~/。vimrc文件——请参阅下面的一些指导方针和最佳实践。
在Vim中使用标签有四种主要方式:
Always keep 'tabstop' at 8, set 'softtabstop' and 'shiftwidth' to 4 (or 3 or whatever you prefer) and use 'noexpandtab'. Then Vim will use a mix of tabs and spaces, but typing and will behave like a tab appears every 4 (or 3) characters. Note: Setting 'tabstop' to any other value than 8 can make your file appear wrong in many places (e.g., when printing it). Set 'tabstop' and 'shiftwidth' to whatever you prefer and use 'expandtab'. This way you will always insert spaces. The formatting will never be messed up when 'tabstop' is changed. Set 'tabstop' and 'shiftwidth' to whatever you prefer and use a |modeline| to set these values when editing the file again. Only works when using Vim to edit the file. Always set 'tabstop' and 'shiftwidth' to the same value, and 'noexpandtab'. This should then work (for initial indents only) for any tabstop setting that people use. It might be nice to have tabs after the first non-blank inserted as spaces if you do this though. Otherwise aligned comments will be wrong when 'tabstop' ischanged.
来源:
vimdoc.sourceforge.net/htmldoc/options.html #“制表符” :帮助制表符