In ubuntu, the vim configuration file is stored in the/etc/Vim directory. The configuration file name is vimrc.
In fedora, the vim configuration file is stored in the/etc directory. The configuration file name is vimrc.
1. display the row number
Add a new line at the end of the file and enter SET nu
2. syntax highlighting
Find "syntax on" in the file and remove the double quotation marks. Double quotation marks indicate the meaning of the comment.
3. Automatic indent
Add a row at the end of the file and enter SET autoindent.
After adding a row, enter SET cindent
Autoindent indicates automatic indent, and cindent indicates automatic indent for C language syntax.
NOTE: If Vim does not take any action after the preceding settings are configured, upgrade Vim to the latest version. Generally, you only need to enter the following command on the terminal: sudo apt-Get install Vim
4. 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
5. Compile the connection without leaving Vim to generate an executable file.
6. Set common hot keys
1) Add the following code to your. vimrc file (~ /. Vimrc)
"This script use to excute make in vim and open quickfix window
Nmap B: Call do_make () <CR>
Nmap c: cClose <CR>
Function do_make ()
Let filename = bufname ("% ")
Let suffix_pos = stridx (filename, ". c ")
If suffix_pos =-1
Return
Else
Let target = strpart (filename, 0, suffix_pos)
Endif
Let target = "make". Target
Execute target
Execute "Copen"
Endfunction
2) In the nomal mode of VI (that is, the command mode, not the command mode by the colon)
Compile the program by SHIFT + B. If an error occurs in the quickfix window, the error line and error message are displayed. Press enter to jump to the error line.
Press SHIFT + C to close the quickfix window.
Note: In VI, Shift + C deletes all characters after the cursor of the row and enters the input mode. If you often use this hot key, please map it yourself. Only C files are supported.
: Map <F2> G <F3>
: Imap <F2> <ESC> <F3>
: Map <F3> go # include <> <ESC>
: Imap <C-D> # define
: Imap <C-F> (;;){}
: Imap <C-W> while (){}
: Imap <C-A> int main (INT argc, char * argv []) {exit (0 );}
I don't know how to use the 5, 6, and later...