1 shiftwidth
This is usedProgramIndicates the white space length used for automatic indent. In general, to keep the program beautiful, it is best to be consistent with the following parameters. It is also the setter of the symbol shift length.
2 tabstop
It is recommended to set the length of spaces equivalent to the tab value to 8, because if it is another value, it may make the file look awkward in printing and other fields. Unless you have setExpandtab
Mode, that is, to convert tabs into spaces, so that it will not be confused. However, after all, 8 is the most common setting, so do not change it.
3 softtabstop
what if we want to change the indentation in the program? shiftwidth
and tabstop
not the same, you will find the program ugly. At this time, softtabstop
it takes effect. You can see from the description in VIM that once the softtabstop
value is set, press the tab key, insert a mix of spaces and Tab tabs. The actual mixing depends on the configured softtabstop
. For example, if softtabstop is set to 8, press the tab key to insert a normal tab. If softtabstop is set to 16, two tabs are inserted. If softtabstop is set to 12, A tab is inserted with four spaces. What if softtabstop
= 4? At the beginning, there are four spaces inserted. Once you press the tab again, the four spaces will be combined with the previous four spaces to become a tab. In other words, softtabstop
is "every 8 spaces into 1 tab ", the premise is that you tabstop = 8
.
4 about expandtab
For example, when multiple developers develop projects togetherCodeThe style should be as consistent as possible. Generally, the Tab character is not allowed in the code, but four spaces are used instead. You can edit an object that contains the following content:
Set shiftwidth = 4
Set expandtab
Then add the following command to. vimrc:
Autocmd filetype C, CPP set shiftwidth = 4 | set expandtab
You can implement this setting only when editing the C and CPP files.
(Original address:
Http://blog.csdn.net/ludonghai715/archive/2010/06/09/5657712.aspx)