The TAB key on the terminal is indented 8 spaces by default (remember that 8 spaces are not equal to a tab, tab, and space are not a concept)
This is usually the case when the tab (tab) indent of Vim is set: Set tabstop=4 "means that the tab width is displayed as the width of the 4 spaces
After setting up you don't think a tab is equal to 4 spaces, they are not equal, when is it equal? Set Expandtab "means tab (tab) becomes a space
After setting up, a 4-space-length tab is equal to 4 spaces.
Attach the settings in vim for auto indent (auto indent required for general line breaks):
Set autoindent "Turn on auto indent
set shiftwidth=4" Auto indent 4 spaces
Set softtabstop=4 "Shiftwidth and TabStop not the same, you will find the program is rather ugly."
At this time, the softtabstop is in effect;
For example, if set softtabstop=8, then press TAB, insert a normal tab, if set softtabstop=16, then insert is two tabs; if softtabstop=12, Then insert a tab character plus 4 spaces;
What if softtabstop=4? At first, the insertion is 4 spaces, and once you press the tab again, this time the four spaces will be combined with the last four spaces into a tab. In other words, Softtabstop is "every 8 spaces into 1 tabs", if you tabstop=8
Here is my vim about indentation configuration: "tab width set tabstop=4set expandtab" Unified indent to 4set Softtabstop=4set shifwidth=4
Indentation is always tab in VI, but some tabs are indented 4 and some are indented 8. How to set it up in the environment?
method One, add Export exinit= "set Showmode tabstop=4" in ~/.BASHRC
method Two, touch ~/.EXRC file. Write set tabstop=4 in the inside
If not, try source ~/.BASHRC
Set vi tab indent in environment variables