When Vim is started, the. vimrc file under the current user's root directory is automatically read, and the file can contain settings or even scripts.
"Set EncodingSet encoding=utf-8Set Fencs=utf-8, Ucs-bom,Shift-Jis,gb18030,gbk,gb2312,cp936set fileencodings=utf-8, ucs-Bom,chinese"Language SettingsSet LANGMENU=ZH_CN. utf-8 "Set Syntax highlightingsyntax Enablesyntax on"set a color schemeColorScheme torte"You can use the mouse anywhere in the bufferSet mouse=Aset Selection=Exclusiveset SelectMode=Mouse,key"Highlight matching parenthesesSet Showmatch"Remove VI ConsistencySet Nocompatible"Set IndentSet tabstop=4Set Softtabstop=4Set Shiftwidth=4Set Autoindentset cindentif&term=="xterm"Set T_co=8Set T_SB=^[[4%DM Set T_SF=^[[3%Dmendif"Open the file type Auto-detect featurefiletype on"Set TagListLet tlist_show_one_file=0 "tags that display multiple filesLet tlist_file_fold_auto_close=1 "non-current file, function list collapse hiddenLet tlist_exit_onlywindow=1 "exit Vim When TagList is the last windowLet tlist_use_singleclick=1 "jump When clickedLet tlist_gainfocus_on_toggleopen=1 "get input focus when opening taglistLet tlist_process_file_always=1 "always parse the tag in the file regardless of whether the TagList window is open "setting up the Winmanager pluginLet g:winmanagerwindowlayout='fileexplorer| TagList'Nmap Wm:wmtoggle<cr>Map<silent> <F9>:wmtoggle<cr>"bind the F9 to Winmanager, which opens the Wimmanager "Set CscopeSet cscopequickfix=s-,c-,d-,i-,t-,e-"sets whether to display cscope results using the Quickfix window "setting up the grep pluginNnoremap <silent> <F3>:grep<cr>"Set one-click compilationMap <F6>: Make<CR>"Set auto-completeFileType plugin indent on"Open File Type detectionSet Completeopt=longest,menu"Turn off the preview window when smart completion is complete "automatically load when a tags is present when you start VimifExists"Tags") Set Tags=./Tagsendif"set the method to update tags by F12Map <F12>: Call Do_cstag () <CR>Nmap<[email Protected]>s:csFindS <c-r>=expand ("<cword>") <CR><CR>:copen<CR>Nmap<[email Protected]>g:csFindG <c-r>=expand ("<cword>") <CR><CR>Nmap<[email Protected]>c:csFindC <c-r>=expand ("<cword>") <CR><CR>:copen<CR>Nmap<[email Protected]>t:csFindT <c-r>=expand ("<cword>") <CR><CR>:copen<CR>Nmap<[email Protected]>e:csFindE <c-r>=expand ("<cword>") <CR><CR>:copen<CR>Nmap<[email Protected]>f:csFindF <c-r>=expand ("<cfile>") <CR><CR>:copen<CR>Nmap<[email Protected]>i:csFindI ^<c-r>=expand ("<cfile>") <CR>$<CR>:copen<CR>Nmap<[email Protected]>d:csFindD <c-r>=expand ("<cword>") <CR><CR>:copen<CR>functionDo_cstag () Letdir=GETCWD ()ifFilereadable ("Tags") if(g:iswindows==1) Let tagsdeleted=delete (dir."\\"."Tags") ElseLet tagsdeleted=delete ("./"."Tags") endifif(tagsdeleted!=0) Echohl warningmsg|Echo "Fail to do tags! I cannot delete the tags"|Echohl None return endif endififHas ("Cscope") Silent! Execute"CS Kill-1"endififFilereadable ("Cscope.files") if(g:iswindows==1) Let csfilesdeleted=delete (dir."\\"."Cscope.files") ElseLet csfilesdeleted=delete ("./"."Cscope.files") endifif(csfilesdeleted!=0) Echohl warningmsg|Echo "Fail to do cscope! I cannot delete the cscope.files"|Echohl None return endif endif /c1>ifFilereadable ("Cscope.out") if(g:iswindows==1) Let csoutdeleted=delete (dir."\\"."Cscope.out") ElseLet csoutdeleted=delete ("./"."Cscope.out") endifif(csoutdeleted!=0) Echohl warningmsg|Echo "Fail to do cscope! I cannot delete the cscope.out"|Echohl None return endif endif /c5>if(Executable ('Ctags')) "silent! Execute"!ctags-r--c-types=+p--fields=+s *"silent! Execute"!ctags-r--c++-kinds=+p--fields=+ias--extra=+q."endifif(Executable ('Cscope') && has ("Cscope") ) if(g:iswindows!=1) Silent! Execute"!find.-name ' *.h '-o-name ' *.c ' -o-name ' *.cpp '-o-name ' *.java '-o-name ' *.cs ' > Cscope.files" ElseSilent! Execute"!dir/s/b *.c,*.cpp,*.h,*.java,*.cs >> cscope.files"endif Silent! Execute"!cscope-b"Execute"Normal:" ifFilereadable ("Cscope.out") Execute"CS Add cscope.out"endif endifendfunction"Set the default shellSet shell=Bash"set the history of Vim RecordsSet history= - "set the file to be read automatically when the file is changed externallyifExists"&autoread") Set Autoreadendif"Set AmbiwidthSet ambiwidth=Double "Set File typeSet ffs=Unix,dos,mac"Set Incremental Search modeSet Incsearch"Set Mute modeset Noerrorbellsset novisualbellset t_vb="do not back up filesSet Nobackupset nowb
According to your own needs to set up, generally I prefer the settings to:
Set encoding=utf-8Set Fencs=utf-8, Ucs-bom,Shift-Jis,gb18030,gbk,gb2312,cp936set fileencodings=utf-8, ucs-Bom,chinese Set Langmenu=zh_cn. utf-8syntax Enablesyntax on set mouse=Aset Selection=Exclusiveset SelectMode=Mouse,key Set Showmatch set nocompatible set TabStop=4Set Softtabstop=4Set Shiftwidth=4set autoindentset cindent filetype onset shell=Bash Set history= -filetype plugin indent on set completeopt=longest,menu
Vim configuration file ~/.VIMRC