[VIM] set VIM syntax highlighting and auto indent

Source: Internet
Author: User

1. Location of configuration files
under Directory/etc/vim, 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, a. vimrc file is usually already present.

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) Do not discuss the tab is 8 or 4 is better, here set (soft) tab width of 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 indentation using the C + + language:
Set Cindent
5) To set the specific indentation for the C + + language (in my Windows style example):
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
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

Ps:
Auto Indent has two options:
Code:
Set Autoindent
Set Cindent

Autoindent is the meaning of automatic indentation, when you insert a new line in the input state, or when you insert a new row in the normal state with O or O, Autoindent automatically copies the indentation of the current line to the new line, which is "auto alignment", of course, If you do not enter any characters in the new line, the indentation is automatically deleted.


Cindent is different, it will automatically adjust the length of indentation according to the C language syntax, for example, when you enter a half statement and then enter, the indentation will automatically add a TABSTOP value, when you type a closing curly brace, will automatically reduce a TABSTOP value 。

[VIM] set VIM syntax highlighting and auto indent

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.