1 shiftwidth
This is the blank length indication used for automatic indentation in the program. 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 set the expandtab mode, that is, to convert tabs into spaces, it will not be confused together. However, after all, the most common setting is to use 8 as a tab, therefore, do not change it.
3 softtabstop
What if we want to change the indentation in the program? If shiftwidth is different from tabstop, you will find the program ugly. At this time, softtabstop will take effect. You can see from the vim description that once the softtabstop value is set, you press the tab key to insert a mix of spaces and tab tabs. The specific mixing depends on the softtabstop you set, 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 = 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", provided that you tabstop = 8.
4 about expandtab
For example, when multiple developers develop projects together, in order to keep the code style as consistent as possible, it is generally not allowed to use the TAB character in the code, instead of four spaces. 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.