From Vim manual:
Option:
1. tabstop: the number of spaces displayed for a tab. The default value is 8.
2. softtabstop: the number of spaces in a tab during editing (for example, press the return or tab key... I didn't fully understand)
3. expandtab/noexpandtab: Expand or not expand the tab into spaces.
4. shiftwidth: the number of spaces for each level of indentation
5. smarttab: determines the number of spaces in a tab based on the number of indentation spaces in other parts of the file.
Command:
: [Range] retab [new_tabstop]: Apply the new tabstop value and replace all tabs. If expandtab is set, all tabs in the file are replaced with spaces.
Common usage:
1. Retain the tab. Keep tabstop by default, set softtabstop and shiftwidth to 4, and set noexpandtab. In this way, if there is a tab in the file, it will be retained, and the new indent will also use the tab.
2. Use spaces for all. Set tabstop and shiftwidth to the same value, for example, 4, and set expandtab. In this way, spaces are used for the new indent. Press the tab key and all spaces are displayed. If there is a tab in the file, you can use the retab command again to extend all tabs into spaces, which is perfect.
I usually set it in. vimrc as follows:
Set smarttab <br/> set tabstop = 4 <br/> set shiftwidth = 4 <br/> set expandtab
Related logs:
Vim tab settings (2): Use autocmd to apply different tab settings for different file types: http://blog.csdn.net/shell_picker/archive/2010/12/13/6073125.aspx