Vim Auto Indent settings

Source: Internet
Author: User
Tags function prototype

Need software
Vim Download Address
http://www.vim.org
Code_complete.vim Plugin
http://www.vim.org/scripts/script.php?script_id=1764
Ctags General after the installation of Vim will have, Ubuntu seems to be not supported, need to download.
A VIM configuration
Reprint of Eric's article, original source
Http://blog.chinaunix.net/u/22968/showart_432269.html
1, the location of the configuration file
& #160; Below the directory/etc/, there is a file called VIMRC, which is a public vim profile in the system and is valid for all users. In each user's home directory, you can create your own private configuration file, named: ". VIMRC". For example, a. vimrc file is usually already present in the/root directory.
& #160;
2. Set syntax highlighting
1 Open VIMRC, add the following statement to make syntax highlighting:
& #160; Syntax on
2 If the syntax is not highlighted at this time, add the following statement to the profile file in the/etc directory:
& #160; Export Term=xterm-color
3. Set up windows C + + Auto Indent (add the following set statement to VIMRC)
& #160; 1 do not discuss whether the tab character is 8 or 4 better, set the (Soft) tab width to 4:
& #160; Set tabstop=4
& #160; Set softtabstop=4
& #160; 2) Set the number of spaces indented to 4
& #160; Set shiftwidth=4
& #160; 3 Set Auto indent: That is, the indentation value of each row is equal to the previous line; Use Noautoindent to cancel the setting:
Set Autoindent
& #160; 4 to set up the automatic indent mode using C + + language:
& #160; Set Cindent
& #160; 5 to set the specific indentation method for A/C + + language (for example, my Windows style):
& #160; Set Cinoptions={0,1s,t0,n-2,p2s, (03s,=.5s,>1s,=1s,:1s
& #160; 6 If you want to display the line number of the text on the left, you can use the following statement:
& #160; Set Nu
& #160; 7 Finally, if you don't have the following statement, add it:
If &term== "Xterm"
& #160; Set T_co=8
& #160; Set T_SB=^[[4%DM
& #160; Set T_SF=^[[3%DM
endif
Ps:
There are two options for automatic indentation: & #160;
Code:
& #160; Set autoindent& #160;
& #160; Set Cindent
& #160; & #160;
& #160 Autoindent is automatically indented, when you insert a new line with the return key in the input state, or insert a new row in the normal state with O or O, Autoindent automatically copies the current line indent to the new line, which is automatically aligned, Of course, if you don't enter any characters on the new line, the indentation is automatically deleted. & #160;
& #160;
& #160; Cindent is different, it automatically adjusts the length of the indentation according to the C language syntax, for example, when you enter half a statement and return, the indentation automatically adds a TABSTOP value, and when you type a right curly brace, a TABSTOP value is automatically reduced.
Two code_complete configuration
Copy the downloaded code_complete to the plugin directory, usually under (my)/usr/share/vim/vim71/plugin
Three use ctags command to generate tags file, ctags-r--c-kinds=+p--fields=+s
You should create an index table, and then copy the generated tags file to your programming directory.
Use the key in vim to complement the full function prototype.
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.