As the saying goes, to do a good job, you must first sharpen the tool. today, I will share with you my vi script configuration. I use f8, and the configuration file is/etc/vimrc, or ~ /. Vimrc. What I am talking about is the configuration added on the F8 basic paper. The setautoindent Auto Indent function does not require manual alignment for each line break.
As the saying goes, to do a good job, you must first sharpen the tool. today, I will share with you my vi script configuration.
I use f8, and the configuration file is/etc/vimrc, or ~ /. Vimrc.
What I am talking about is the configuration added on the F8 basic paper.
Setautoindent Auto Indent function, no manual alignment required for each line feed
Setsmartindent smart alignment, good for writing c/c ++
Settabstop = 4
Setshiftwidth = 4 TAB key = 4 spaces (International Standard)
Setignorecase search is no longer case sensitive, and it is difficult to switch back and forth between many cases, which makes it much easier to remember.
Setincsearch: intelligent search. when you search for a word, it is highlighted based on the corresponding letter. you do not need to finish all the text before displaying it. it is very helpful for searching for long keywords and you do not have to worry about forgetting words.
The above are several simple configuration attributes of vim. everyone knows the power of vim and can even use plug-ins to form the IDE mode.
People get used to the problem. based on the simple and concise principle, the above few simple settings will be left in the end, but the dual is enough ......
Several useful commands are also mentioned.
1) vi-d file1 file2 ------ file comparison function, very convenient
2) edit a file and open another file: spfile or: horizontal and vertical comparison of the vsp file. ctrl + w switches between the files, so it is good to copy and compare the files.
3) function prototype search and data structure prototype search. now, the common vi installation comes with ctags, which is convenient for simple search, run $ ctags-R * in the source code directory. after execution, a tag file will be created under the code directory, when reading the code, if you want to search for the prototype and data definition of the function, use ctrl +] to jump directly, and return ctrl + t. Very simple and convenient.
Add two, tracking files
: $ Directly at the bottom of the file
: Num directly reaches the Num row
: 0 directly to the top
If a tag exists, directly use the vi-t function name to directly access the function location in the file.
/********************************** Vimrc **** ***********************/
If v: lang = ~ "Utf8 $" | v: lang = ~ UTF-8 $"
Set fileencodings = UTF-8, latin1
Endif
Set autoindent
Set smartindent
Set tabstop = 4
Set softtabstop = 4
Set shiftwidth = 4
Set ignorecase
Set incsearch
Set nocompatible "Use Vim defaults (muchbetter !)
Set bs = indent, eol, start "allow backspacingover everything in insert mode
"Set ai" always setautoindenting on
"Set backup" keep a backup file
Set viminfo = '20,/"50" read/write a. viminfo file, don't store more
"Than 50 linesof registers
Set history = 50 "keep 50 lines of commandline history
Set rsor "show the cursor position allthe time
"Only do this part when compiled with support forautocommands
If has ("autocmd ")
"In text files, always limit the width of text to 78 characters
Autocmd BufRead *. txt set tw = 78
"When editing a file, always jump to the last cursorposition
Autocmd BufReadPost *
/If line ("'/" ")> 0 & line ("'/"") <= line ("$") |
/Exe "normal! G'/"" |
/Endif
Endif
If has ("CSAs") & filereadable ("/usr/bin/csable ")
Set csprg =/usr/bin/cs.pdf
Set csto = 0
Set cst
Set nocsverb
"Add any database in current directory
If filereadable ("cscope. out ")
Cs add cscope. out
"Else add database pointed to by environment
Elseif $ CSCOPE_DB! = ""
Cs add $ CSCOPE_DB
Endif
Set csverb
Endif
"Switch syntax highlighting on, when the terminal hascolors
"Also switch on highlighting the last used search pattern.
If & t_Co> 2 | has ("gui_running ")
Syntax on
Set hlsearch
Endif
Filetype plugin on
If & term = "xterm"
Set t_Co = 8
Set t_Sb = ^ [4% dm
Set t_Sf = ^ [3% dm
Endif
"Don't wake up system with blinking cursor:
Http://www.linuxpowertop.org/known.php
Let & guicursor = & guicursor. ", a: blinkon0"