1. Location of configuration files
Under directory/etc/, there is a file named VIMRC, which 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, under the/root directory, there is usually already one. VIMRC file.
If you do not know the location of the configuration file and script, you can use the command in VIM: Scriptnames, the following path will be displayed
/etc/vimrc
/usr/share/vim/vim72/syntax/syntax.vim
/usr/share/vim/vim72/syntax/synload.vim
/usr/share/vim/vim72/syntax/syncolor.vim
/usr/share/vim/vim72/filetype.vim
/usr/share/vim/vim72/ftplugin.vim
/home/kdj/.vimrc
...
If you do not know the search location for the Vim configuration file, enter: version, which will be displayed
System VIMRC File: "/ETC/VIMRC"
User VIMRC file: "$HOME/.VIMRC"
User EXRC file: "$HOME/.EXRC"
$VIM preset value: "/usr/share/vim"
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-style C + + Auto Indent (add the following set statement to VIMRC)
1) Set (soft) tab width to 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 line; Use Noautoindent to cancel the setting:
Set Autoindent
4) Set the automatic indent mode using C/C language:
Set Cindent
5) Set the specific indentation of the C/C language (for example in my Windows style):
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
Set Roler settings cursor display
7) Finally, if you do not have the following statement, add it:
If &term== "Xterm"
Set T_co=8
Set T_SB=^[[4%DM
Set T_SF=^[[3%DM
endif
Vim Syntax highlighting