Vim Programming Configuration Method

Source: Internet
Author: User

About VIM
Vim has the following modes:
1) Normal mode, the default editing mode, the following if no special instructions, the mentioned commands are directly in normal mode input, any other mode can be on the keyboard Esc key back to normal mode.
2) command mode for longer, more complex commands, enter ":" (General Command), "/" (forward lookup), or "?" in normal mode. (Reverse lookup) to enter the mode, command mode commands to enter the return (enter) is not complete.
3) Insert mode, use when entering text, type "I" (insert) or "a" (append) in normal mode to enter insert mode (there are also other commands, such as "C", can also go into insert mode, but these commands have other functions).
4) Visual (visual) mode for selecting blocks of text, you can enter "V" in normal mode (lowercase) to select by character, enter "V" (uppercase) to select by row, or enter "Ctrl-v" to select by a square.
5) Select (select) mode, which is closer to the normal Windows editor to select a block of text, and after selecting a block of text in one of the visual and selection modes, you can use "ctrl-g" to switch to another mode-the pattern is rarely used on Linux and is no longer covered in this article.
U set vim syntax highlighting and auto indent

Second, the configuration file of the next set vim

1. Location of configuration files
Under directory/etc/, 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) Set (soft) tab width to 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

Vim Programming Configuration Method

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.