Vim practical configuration)

Source: Internet
Author: User

When Vim is used in the terminal for editing, by default, no line number, high syntax brightness, and smart indentation are displayed on the editing interface.

. To better work in Vim, You need to manually set a configuration file:. vimrc.
When Vim is started, the. vimrc file under the root directory of the current user will be automatically read. This file can contain some settings or even scripts,

Therefore, it is easier to create the. vimrc file in the root directory of the current user. The command is:
$ VI ~ /. Vimrc
After setting
$: X or $ WQ
Save and exit.
The following example shows the frequently used settings. For detailed settings, see references:
"Behavior comment line starting with double quotation marks, the same below

 "  Remove the annoying VI consistency mode to avoid bugs and limitations in earlier versions.  
Set nocompatible
" Show row number
Set number
" Check file type
Filetype on
" Number of historical rows
Set history = 1000
" Black Background
Set background = dark
" Syntax High Brightness Display
Syntax on
" The following two lines are being written:CodeIs useful in the format;
" In the first line, VIM uses automatic start, that is, to apply the format of the current row to the next line;
" The second line is to intelligently select the start method based on the preceding start format.
" Writing is useful.
Set autoindent
Set smartindent
" The first line sets the tab key to 4 spaces, and the second line sets to use 4 spaces when the lines are staggered.
Set tabstop = 4
Set shiftwidth = 4
" Set the matching mode, similar to the right brace that will be matched when a left brace is entered.
Set showmatch
" Remove toolbar from the GUI version of VIM
Set guioptions = T
" When Vim is edited, if the command is incorrect, a sound will be triggered, and this setting removes the sound.
Set VB t_vb =
" The status line at the cursor position is displayed in the lower right corner of the editing process.
Set ruler
" By default, the search for matching is displayed in High Brightness. This setting disables the highlighted display.
Set nohls
" It is very convenient to query. If you want to find the book word, the first word is automatically found when/B is entered.
" A word starting with B. When the word/bo is entered, the word starting with the first Bo is automatically found.
" And so on. You can use this setting to quickly find the answer.
" Do not forget to press ENTER
Set incsearch
" After a file is modified, it is automatically backed up. The backup file name is added to the original file name " ~ " Suffix
If Has ( " VMS " ) // Note that double quotation marks must be half-width quotation marks. " "
Set nobackup
Else
Set backup
Endif

 

After the annotation is removed, a complete. vimrc configuration is as follows:

 Set Nocompatible
Set Number
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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.