1
Install vim
Ubuntu has only pre-installed VI (Vim-tiny), but has not installed Vim. It can only be installed manually. Vim & gvim
Sudo apt-get install vim-gnome
2
, Configuration file location
In the Directory
/Etc/Vim/
Below, there is
Vimrc
File, which is public in the system
Vim
Configuration file, which is valid for all users.
3
Set syntax highlighting
1)
Open
Vimrc
To highlight the Syntax:
Syntax on
2)
If the syntax is still not highlighted
/Etc
Directory
Profile
Add the following statement to the file:
Export TERM = xterm-color
3) Solve the Problem of invalid direction keys and backspace keys (using incompatible Mode)
Set nocompatibleset backspace = 24
, Settings
Windows
Style
C/C ++
Auto indent (Add the following
Set
Statement
Vimrc
Medium)
1
)
Set the (soft) tab width
4
:
Set tabstop = 4
Set softtabstop = 4
2
)
Set the number of spaces for indentation.
4
Set shiftwidth = 4
3
)
Set automatic indent
: The indentation value of each line is equal to that of the previous line.
Noautoindent
Unset:
Set autoindent
4
)
Set
Use
C/C ++
Automatic language indentation:
Set cindent
5
) Settings
C/C ++
Specific language indentation
:
Set cinoptions = {s, t0, N-2, p2s, (03 s, =. 5 s,> 1 s, = 1 s,: 1 s
6
) To display the line number of the text on the left, use the following statement:
Set nu
7
) Finally, if the following statements are not available, add them:
If & term = "xterm"
Set t_Co = 8
Set t_Sb = ^ [4% dm
Set t_sf = ^ [3% DM
Endif
========================================================== ========================================================== ======================================= Ubuntu
In 10.10, VIM is not installed by default, and only VI is used. The functions of the two are similar, but Vim is an upgraded version of VI, which can only be improved. Therefore, we recommend that you install the upgraded version of vim.
Make sudo apt-Get install Vim
Install the complete Vim version 7.2. This version does not support syntax highlighting and file type detection. However, based on my experience, the syntax highlighting function is still available, others can be configured by yourself.
The default configuration file of VIM is:/etc/Vim/vimrc.
You can create your own configuration files in the Home Directory (which is a commonly used main folder.
Switch to the Home Directory # Cd ~
Touch a file named. vimrc (hidden files starting with. Can be displayed and hidden by pressing CTRL + H)
# Touch. vimrc
# Vi. vimrc
Enter the following Configuration:
Set nocompatible does not use the default VI keyboard layout <---- this is very important. If it is not configured, it is annoying to enter characters by pressing the direction key in editing mode.
Set Number Display row number
Set autoindent Automatic Alignment
Set smartindent smart alignment
Set showmatch matching mode
Set ruler display status line
Set incsearch
Set tabstop = 4 The Tab key is 4 spaces
Set shiftwidth = 4
Set softtabstop = 4
Set cindent C language format alignment
Set nobackup does not Back Up Files
Set clipboard + = unnamed shares the clipboard with Windows
// The following lines eliminate vim Chinese garbled characters
Set fileencodings = UTF-8, gb2312, gbk, gb18030
Set termencoding = UTF-8
Set encoding = prc
Save and exit!