Vim Auto Indent configuration

Source: Internet
Author: User
Tags function prototype


Need software
VIM
http://www.vim.org
Code & complete.vim plug in
http://www.vim.org/scripts/script.php?script_id=1764
Ctags usually come after VIM is installed. Ubuntu doesn't seem to support it. You need to download it
One VIM configuration
Reprint of Eric's article
http://blog.chinaunix.net/u/22968/showart_432269.html
1. Location of profile
Under the directory / etc /, there is a file named vimrc, which is the public VIM configuration file in the system, and is valid for all users. In the home directory of each user, you can create a private configuration file named ". Vimrc". For example, in the / root directory, a. Vimrc file usually already exists.
2. Set syntax highlighting
1) Open vimrc and add the following statement to highlight the syntax:
Syntax on
2) If the syntax is not highlighted at this time, add the following statement to the profile file in the / etc Directory:
export TERM=xterm-color
3. Set windows Style C / C + + auto indent (add the following set statement to vimrc)
1) It is better not to discuss whether the tab is 8 or 4. Here, set the (soft) tab width to 4:
set tabstop=4
set softtabstop=4
2) Set the number of indented spaces 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 setting:
set autoindent
4) Set the auto indent method using C / C + +:
Set cindent
5) Set the specific indentation method of C / C + + language (take my windows style as an 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 don't have the following statements, add them:
if &term=="xterm"
Set t_Co=8
set t_Sb=^[[4%dm
set t_Sf=^[[3%dm
Endif
PS:
There are two options for automatic indenting:
Code:
set autoindent
Set cindent
Autoindent means auto indent. When you use enter to insert a new line in the input state, or O or O to insert a new line in the normal state, autoindent will automatically copy the indent of the current line to the new line, that is, auto align. Of course, if you do not enter any characters in the new line, the indent will be automatically deleted.
Cindent is different. It will automatically adjust the length of the indentation according to the syntax of C language. For example, when you enter half a statement and then enter, the indentation will automatically increase a tabstop value, and when you type a right curly bracket, it will automatically reduce a tabstop value.
Two code "complete configuration
Copy the downloaded code [u complete] to the plugin directory, usually under (my is) / usr / share / VIM / vim71 / plugin
Three uses C tags command to generate tags file, ctags - R -- c-kings = + P -- fields = + S
You should build the index table, and then copy the generated tags file to your programming directory.
Using the key in VIM can complete the function prototype.





Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.



Vim Auto Indent configuration


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.