Vim auto indent 1, install vim sudo apt-get install vim-full1, the configuration file is located under the directory/etc/, there is a file named vimrc, this is a public vim configuration file in the system and is valid for all users. In each user's home directory, you can create a private configuration file named ". vimrc ". For example, A. vimrc file already exists in the/root directory. 2. Set syntax highlighting 1) Open vimrc and add the following statement to highlight the syntax: syntax on2) if the syntax is still not highlighted, then add the following statement in the profile file under the/etc directory: export TERM = xterm-color3, set Windows style C/C ++ auto indent (Add the following set statement to vimrc) 1) It is not discussed whether it is better to set the tab to 8 or 4. Here, set the (soft) tab width to 4: set tabstop = 4 set softtabstop = 4 2) set the number of spaces for indentation to 4 set shiftwidth = 4 3) set automatic indent: that is, the indent value of each line is equal to that of the previous line; Use noautoindent to unset: set autoindent 4) set the automatic indent mode for C/C ++ language: set cindent 5) set the specific indent mode for C/C ++ language (take my windows style as an example): set cinoptions = {S, t0, N-2, p2s, (03 s, =. 5 s,> 1 s, = 1 s,: 1 s 6) If you want to display the line number of the text on the left, you can use the following statement: set nu 7) Finally, if you do not have the following statements, add them: if & term = "xterm" set t_Co = 8 set t_Sb = ^ [[4% dm set t_Sf = ^ [3% dmendif PS: there are two options for automatic indent: Code: set autoindent set cindent autoindent indicates automatic indent. When you insert a new line in the input state, alternatively, when a new row is inserted with o or O in the normal state, autoindent automatically copies the indentation of the current row to the new row, that is, "auto-alignment". Of course, if you do not enter any characters in the new line, the indent is automatically deleted. Cindent is different. It will automatically adjust the indent length according to the C language syntax. For example, when you enter half a statement and press enter, the indent will automatically add a TABSTOP value, when you type a right curly braces, a tabstop value is automatically reduced.