In the terminal under the use of Vim for editing, by default, the editing interface is not displayed line number, syntax high-brightness display, intelligent indentation and other functions.
In order to better work under VIM, you need to manually set a profile:. vimrc.
When Vim is started, the. vimrc file in the current user root directory is automatically read, and the file can contain settings and even scripts, so it is generally convenient to create a. vimrc file under the current user's root directory, that is, the command created is:
$vi ~/.VIMRC
When you are finished setting up
$:x or $wq
To save and exit.
Here is an example of a list of settings that are often used, and for detailed setup information, refer to the resources:
"Double quotation marks the start of the behavior Comment Line, hereinafter
"Get rid of annoying about VI consistency mode, avoid some bugs and limitations of previous versions
Set nocompatible
"Show line numbers
Set Nummber
The type of the detection file
FileType on
"Record the number of rows in history
Set history=1000
"Background uses black
Set Background=dark
"Syntax High brightness display
Syntax on
"The following two lines are useful for formatting when you are writing code;
"The first line, Vim uses automatic alignment, which is to apply the current row's alignment format to the next line;
"The second line, based on the above format, the intelligent choice of the way, for a similar C-language
"It's useful to write.
Set Autoindent
Set Smartindent
"The first line sets the TAB key to 4 spaces, and the second row sets the use of 4 spaces when the rows are interleaved
Set tabstop=4
Set shiftwidth=4
"Sets the matching pattern, similar to the corresponding closing parenthesis when an opening parenthesis is entered
Set Showmatch
"Remove toolbar from the GUI version of Vim
Set guioptions-=t
"When Vim is editing, if the command is wrong, it makes a noise and the setting removes the noise
Set VB t_vb=
"Displays the status line of the cursor position in the lower-right corner during the editing process
Set ruler
"By default, finding a match is a high brightness display, and this setting turns off highlighting
Set Nohls
"Query is very convenient, if you want to find the book Word, when entered/b, will automatically find the first
"A word that begins with B, and when entered into/bo, it automatically finds the first word that begins with a Bo, depending on
"By analogy, when looking, use this setting to quickly find the answer when you find a word to match
"When, don't forget to enter
Set Incsearch
"After a file is modified, the backup is automatically backed up with the original file name plus the" ~ "suffix
If has ("VMS")
Set Nobackup
Else
Set backup
endif
If you remove the annotation, a complete. VIMRC configuration information is shown below:
Copy Code code as follows:
Set nocompatible
Set Nummber
FileType on
Set history=1000
Set Background=dark
Syntax on
Set Autoindent
Set Smartindent
Set tabstop=4
Set shiftwidth=4
Set Showmatch
Set guioptions-=t
Set VB t_vb=
Set ruler
Set Nohls
Set Incsearch
If has ("VMS")
Set Nobackup
Else
Set backup
endif
If the discovery function does not work after Setup, check to see if the vim-enhanced package is installed under the system, and the query command is:
$rpm –q vim-enhanced
Resources:
1. The full translation of Vim can be found at the link below
http://vimcdoc.sourceforge.net/
Can be planted in one of the PDF version, which is described in detail, strongly recommended:
2. More detailed vim information can be accessed by:
http://www.vim.org/
3. An example of a. VIMRC with an English annotation.
http://www.vi-improved.org/vimrc.php
On the issue of VI color, the Internet to find a number of articles just to finish, their own summary.
The VI in CentOS only installs the vim-minimal-7.x by default. So whether the input VI or VIM to view the file, the syntax function can not be enabled normally. It is therefore necessary to install the other two components with Yum: vim-common-7.x and vim-enhanced-7.x.
The command line is typed: yum-y install vim-enhanced, Yum automatically installs the two components. Then it can be in vim: syntax on can take effect.
But this is still inconvenient, now only use Vim will be "brilliant", with VI or a "whiteboard."
So, find/ETC/BASHRC (processing alias file), add alias vi= ' Vim ' (give vim the individual name VI ...) ;
Edit/ETC/VIMRC (Vim's configuration file) and add a sentence syntax on.
If you want VI to display the number of rows, you can also add set Nu.
Want to use in VI to determine the location using the mouse, with set mouse=a
Using root login under CentOS, you will see no syntax highlighting when performing VI.
The general system by default to the VI alias to VIM.
Add an alias to the. BASHRC and fix it.
Copy Code code as follows:
VI ~/.BASHRC
Alias Vi= ' Vim '
VI ~/.VIMRC
Syntax on
Set ShowCmd "Show (partial) command in the status line.
Set Showmatch "Show matching brackets.
Set ignorecase "Do case insensitive matching
Set Smartcase "Do smart case matching
Set Incsearch "Incremental Search
Set Autowrite "Automatically save before commands Like:next And:make
Set hidden "Hide buffers when they are abandoned
The above is the entire content of this article, I hope to give you a reference, but also hope that we support the cloud habitat community.