Software required Vim Http://www.vim.org Code_complete.vim plug-in Http://www.vim.org/scripts/script.php? Script_id = 1, 1764 Ctags are usually available after vim is installed. It is not supported in ubuntu and needs to be downloaded. 1. vim Configuration Reprinted Eric's article, source of the original article Http://blog.chinaunix.net/u/22968/showart_432269.html 1. Configuration File Location Under the/etc/directory, 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, A. vimrc file already exists in the/root directory.
2. Set syntax highlighting 1) Open vimrc and add the following statement to highlight the Syntax: Syntax on 2) If the syntax is still not highlighted, add the following statement to the profile file in the/etc directory: Export TERM = xterm-color 3. set Windows C/C ++ auto indent (Add the following set statement to vimrc) 1) It is not discussed whether it is better to set the tab to 8 or 4. Here, set the (soft) tab width to 4: Set tabstop = 4 Set softtabstop = 4 2) set the number of spaces for indentation to 4. Set shiftwidth = 4 3) Set automatic indent: that is, the indent value of each line is equal to that of the previous line; Use noautoindent to cancel the settings: Set autoindent 4) set the automatic indent mode in C/C ++ language: Set cindent 5) set the specific indent mode for C/C ++ language (taking my windows style as an example ): Set cinoptions = {s, t0, N-2, p2s, (03 s, =. 5 s,> 1 s, = 1 s,: 1 s 6) to display the line number of the text on the left, use the following statement: Set nu 7) Add the following statement if it does not exist: If & term = "xterm" Set t_Co = 8 Set t_Sb = ^ [4% dm Set t_Sf = ^ [3% dm Endif PS: Automatic indent has two options: Code: Set autoindent Set cindent
Autoindent means automatic indentation. When you Insert a new row with the Enter key in the input state or Insert a new row with o or O in the normal state, autoindent automatically copies the indentation of the current row to the new line, that is, "auto-alignment". 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 indent length according to the C language syntax. For example, when you enter half a statement and press enter, the indent will automatically add a TABSTOP value, when you type a right curly braces, a tabstop value is automatically reduced. 2. code_complete Configuration Copy the downloaded code_complete to the plugin Directory, which is usually under/usr/share/vim/vim71/plugin. 3. Use the ctags command to generate the tags file. The ctags-R -- c-kinds = + p -- fields = + S Create an index and copy the generated tags file to your programming directory. Use the key in vim to complete the function prototype.
This article is from the ChinaUnix blog. If you want to view the original text, click:Http://blog.chinaunix.net/u2/74761/showart_1096872.html |