Vim line number, syntax display, and other settings, that is, the configuration of the. vimrc File

Source: Internet
Author: User

Reprinted from: http://blog.163.com/zhang_sheng_cun/blog/static/46288667200792604435190/

Http://hi.baidu.com/istang/blog/item/b8a38d6e0d0f1fd780cb4a2b.html

When you use vim to edit a terminal, by default, the editing interface does not display line numbers, syntax High Brightness Display, smart indentation, and other functions. To better work in vim, You need to manually set a configuration file:. vimrc.

When vim is started. the vimrc file is automatically read, which can contain some settings or even scripts. the vimrc file is easy to create in the root directory of the current user, that is, the command to create is:

$ Vi ~ /. Vimrc

After setting

$: X or $ wq

Save and exit.

The following example shows the frequently used settings. For detailed settings, see references:

"Comments rows starting with double quotation marks, the same below

"Remove the annoying vi consistency mode and avoid bugs and limitations in earlier versions.

Set nocompatible

"Show row number

Set nummber

"Detection file type

Filetype on

"Records the number of historical rows

Set history = 1000

"Black is used for background

Set background = dark

"Syntax High Brightness Display

Syntax on

"The following two lines are useful in the format when writing code;

"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, based on the preceding setup format, intelligently selects the setup method.

"Writing is very useful.

Set autoindent

Set smartindent

"The tab key of the first line is set to 4 spaces, and the second line is set to use 4 spaces when 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 vim's GUI version

Set guioptions-= T

"When vim is being edited, if a command error occurs, a sound will be triggered. This setting removes the sound.

Set vb t_vb =

"The status line at the cursor position is displayed in the lower right corner during editing.

Set ruler

"By default, matching is displayed in High Brightness. This setting turns off the highlighted display.

Set nohls

"It is very convenient to query. To search for the book word, when/B is entered, the first

"A word starting with B. When it is input to/bo, it will automatically find the word starting with the first bo, according

"And so on, you can use this setting to quickly find the answer.

"Don't 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 ")

Set nobackup

Else

Set backup

Endif

After the annotation is removed, a complete. vimrc configuration is 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 function does not work after setting, check whether the vim-enhanced package is installed in the system. The query command is:

$ Rpm-q vim-enhanced

References:

1. Complete vim translation can be found at the following link

Http://vimcdoc.sourceforge.net/

You can download one of the PDF versions, which are described in detail. We strongly recommend that you :)

2. For more detailed vim information, visit:

Http://www.vim.org/

3. A. vimrc example with an English note

Http://www.vi-improved.org/vimrc.php

========================================================== ========================================================== ==================================

========================================================== ========================================================== ==================================

I have found several articles on the Internet to solve the vi color problem. I will summarize it myself.

In Centos, only vim-minimal-7.x is installed by default. Therefore, whether you enter vi or vim to view files, the syntax function cannot be enabled normally. Therefore, you need to install the other two components with yum: vim-common-7.x and vim-enhanced-7.x.

Run yum-y install vim-enhanced in the command line to automatically install the two components. In vim, syntax on takes effect.

However, this is not convenient. Currently, only vim can be used to make a lottery. vi is used as a "whiteboard ".

Then, find/etc/bashrc (the file that processes the alias) and add alias vi = 'vim '(to give vim the name of vi ...);

Edit/etc/vimrc (vim configuration file) and add syntax on.

If you want vi to display the number of rows, you can also add set nu.

To use the mouse in vi to determine the position, use set mouse =

Use root login under CentoS. No syntax highlighting is found during vi Execution.
By default, vi alias is switched to vim.

Add alias to. bashrc and complete the operation.
Vi ~ /. Bashrc
Alias vi = 'vim'

Vi ~ /. Vimrc
Syntax on
Set showcmd "Show (partial) command in 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


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.