For vim to better support Python to write code, modify the tab default 4 spaces There are two ways to set up:
1. VIM/ETC/VIMRC
2. VIM/ETC/VIMRC
The second is recommended, which results in 4 spaces when you press the TAB key, which has the best compatibility. Set Tab in Vim
Indentation tab or space, this is not a problem, just like python with four spaces to indent, this is to see a person's preferences. In Vim, it is convenient to set the Tab tab or space according to different file types, and also to set the length, which is very flexible.
First, let's see how to set the tab width and how to determine whether to use Tab tab or empty Glyd to represent an indentation:
Set tabstop=4
Set softtabstop=4
Set shiftwidth=4
Set Noexpandtab/expandtab Description:
Which tabstop
represents the length of how many spaces a tab displays, default 8.
softtabstop
Indicates that the length of the indent is returned when you press the BACKSPACE bar while in edit mode, expandtab
especially useful when used.
shiftwidth
Indicates the length of each level of indentation, generally set to the softtabstop
same.
When set expandtab
to, indentation is represented by an empty glyd, and noexpandtab
a tab is used to denote an indentation.
To set tab according to file type:
Sometimes you want to set different tab performance for certain types of files, such as Python with four empty glyd for an indentation, and four null glyd for indentation in our JavaScript conventions, and HTML and CSS like tab tabs to indent, so you can do the following:
If has ("Autocmd")
Autocmd FileType javascript setlocal ts=4 sts=4 sw=4 expandtab
Autocmd FileType python setlocal ts=4 sts=4 sw=4 expandtab
endif
So when the file is .js
.py
opened, it will be indented with four spaces.
So found that after the tab is not four spaces, is a tab, I need to press TAB instead of four spacebar, so remove sts=4, fix
To represent tab tabs with special symbols:
In Vim, you can use special symbols to represent a tab tab so that tab tabs and spaces can easily be distinguished, such as:
To join in VIMRC:
Set list
Set listchars=tab:?\, EOL:? Reference: http://blog.sina.com.cn/s/blog_620ccfbf01010erz.html
Vim tab is set to 4 spaces