1, set the location of the file
Under directory/etc/vim, there is a file named VIMRC, which is the public vim settings file in the system and is valid for all users. In each user's home directory, you can create your own private settings file, named: ". VIMRC". For example, under the/root directory, a. vimrc file is usually already present.
2. Set syntax highlighting
1) Open VIMRC and add the following statement to make syntax highlighting:
Syntax on
2) If the syntax is not highlighted at this point, then add the following statement in the profile file in the/etc directory:
Export Term=xterm-color
3. Set the Windows system-style C + + Auto Indent (add the following set statement to VIMRC)
1) Do not discuss the tab is 8 or 4 is better, here set (soft) tab width of 4:
Set tabstop=4
Set softtabstop=4
2) Set the number of spaces in the indent to 4
Set shiftwidth=4
3) Set auto indent: The indent value of each line is equal to the previous one; Use Noautoindent to cancel the setting:
Set Autoindent
4) Set the automatic indentation using the C + + language:
Set Cindent
5) To set the specific indentation for the C + + language (in my Windows style example):
Set Cinoptions={0,1s,t0,n-2,p2s, (03s,=.5s,>1s,=1s,:1s
6) If you want to display the line number of the text on the left, you can use the following statement:
Set Nu
Ps:
Auto Indent has two options:
Code:
Set Autoindent
Set Cindent
Autoindent is the meaning of automatic indentation, when you insert a new line in the input state with the Enter, or in the normal state with O or O
When inserting a new row, autoindent
Automatically copies the indentation of the current line to a new line, which is automatically aligned, and, of course, if you don't enter all characters in the new line, the indentation is automatically deleted.
Cindent is different, he will automatically adjust the length of indentation according to the C language syntax, for example, when you enter a half statement and then enter, the indentation will automatically add a TABSTOP value, when you type a right curly brace, will automatically reduce a TABSTOP value. 4, the general solution: directly in the VIMRC file at the back of the add:
Set IC
Set Nu
Set tabstop=4//Sets tab width to 4
Set softtabstop=4//Set (Soft) tab Width 4
Set shiftwidth=4
Set Cindent
Set Smartindent
Set ShowCmd
Then exit and the modification is complete.
Vim settings under Linux