Newly installed system, vim when editing, tab indentation too, used to set the style or four spaces. Online search for someone else's set, very good, copy over. Original Address: https://www.jb51.net/article/143281.htm
Profile location: / etc / virc and / etc / vimrc (_zxq Note: Our system is ubuntu16.04, the configuration file: / etc / vim / vimrc)
Configuration file if you want to add comments, can not use #, to use "
1
2
3
4
5
6
|
" add by school1024.com
set
ts=4
set
softtabstop=4
set
shiftwidth=4
set
expandtab
set
autoindent
|
- ts is the abbreviation tabstop, the width is set TAB 4 spaces.
- It represents softtabstop press the backspace key when in the retracted length indented when the edit mode is particularly useful when used expandtab.
- shiftwidth represents a length of each indentation is generally provided like softtabstop.
- expandtab represented by spaces for indentation, noexpandtab is represented by a tab indentation.
- autoindent automatic indentation
On the previous file you can use the following command spaces and TAB swap
TAB replaced with spaces
1
2
3
|
:
set
ts=4
:
set
expandtab
:%retab!
|
Replace spaces TAB
1
2
3
|
:
set
ts=4
:
set
noexpandtab
:%retab!
|
Plus! After TAB is used to treat non-whitespace characters that all TAB, if not plus!, Only the first line treatment of TAB.