Install the plugin management tool first pathogen
Create a directory ~/.vim/bundle/pathogen/autoload/
Download Pathogen.vim (Https://github.com/tpope/vim-pathogen) to ~/.vim/bundle/pathogen/autoload/
Add the following two lines to the. vimrc
Runtime Bundle/pathogen/autoload/pathogen.vim
Execute Pathogen#infect ()
other plug-ins downloaded after decompression, are copied to the ~/.vim/bundle/directory can be
Bookmark Plugin
Https://github.com/huxiao/vim-bookmark
Https://github.com/MattesGroeger/vim-bookmarks (this plug-in to cooperate with CTRLP to use)
Nmap <F2> MN
IMAP <F2> <ESC>MN
Let g:bookmark_sign = '
Let G:BOOKMARK_DISABLE_CTRLP = 1
Basic usage of Plug-ins:
MM is used to set or delete a bookmark, or to use the command Vbookmarktoggle
MN is used to jump to the next bookmark, or to use the command Vbookmarknext
The MP is used to jump to the previous bookmark, or to use the command vbookmarkprevious
Ma to display all bookmarks
MC Delete a Bookmark
MX Delete all bookmarks
Let G:vbookmark_bookmarksavefile = $HOME. '/.vimbookmark '
"Set shortcut keys for jump bookmarks
Nmap <F2> MN
IMAP <F2> <ESC>:W<CR>MN
C + + STL syntax highlighting plugin
Https://github.com/octol/vim-cpp-enhanced-highlight
Switch between C + + source files and header files
Https://github.com/derekwyatt/vim-fswitch
Nmap <silent> <Leader>sw:FSHere<cr>
In this way, you can switch between the CPP file and the H file by typing SW
The other one is
Https://github.com/vim-scripts/a.vim
: A switches to the header file corresponding to the current file being edited (or vise versa)
: as Splits and switches< C1/>:av Vertical Splits and switches
: at new tab and switches: A cycles through matches
: IH switches to File Under cursor
: IHS splits and switches: IHV vertical-Splits and
switches:
IHT new tab
and switches: ihn CYC Les through matches
<leader>ih switches to file under cursor-<leader>is to the switches alternate
E of file under cursor (e.g. on <foo.h> switches to foo.cpp) <leader>ihn cycles through matches
Nnoremap <leader>av:AV<CR>
Nnoremap <leader>as:AS<CR>
Quick Switch Annotation
Https://github.com/scrooloose/nerdcommenter
Common operations:
<LEADER>CC, note the currently selected text, if the whole line is selected, add/////, if the selected part of the row is added to or before or after the selection;
<LEADER>CU, uncheck the comment for the text block.
You can also call <leader>c<SPACE>, and it will choose to annotate or uncomment it based on whether there are any comments.
Bracket Quotes Auto-complement
Https://github.com/Raimondi/delimitMate
Or
Https://github.com/jiangmiao/auto-pairs
Engineering Document Browsing
Https://github.com/scrooloose/nerdtree
Add the following information to the. VIMRC:
"Use the Nerdtree plug-in to view the project files. Set shortcut keys
Nmap <F8>:nerdtreetoggle<cr>
Set Nerdtree child window width let
nerdtreewinsize=32
set nerdtree child window position let
nerdtreewinpos= ' right '
Show hidden file
Let Nerdtreeshowhidden=1
"nerdtree child window does not display redundant help information let
nerdtreeminimalui=1
" Delete files automatically delete files corresponding to the buffer let
Nerdtreeautodeletebuffer=1
Common operations: Enter, open the selected file, R, refresh the project directory file list, I (uppercase), Show/Hide hidden files, m, create/delete/cut/Copy Operations list. After you type <LEADER>FL, the right child window is a list of project files
Ctags
After downloading the source code package from http://ctags.sourceforge.net/, unzip the build source code directory, and then go to the source code root to execute./configure, then execute make and execute make after the compilation succeeds install
In. VIMRC, add the following settings
Nmap<leader>r:!ctags-r<cr>
In this way, in VIM, press <leader> + R to generate the current directory tags file
Automatically generate blank function body in CPP file according to function declaration in header file
Protodef (http://www.vim.org/scripts/script.php?script_id=2624)
Protodef need to rely on Perl, Ctags and Fswitch (http://www.vim.org/scripts/script.php?script_id=2590)
After installing the Protodef, add the following configuration to the. VIMRC
The implementation order of the Set pullproto.pl script path let
g:protodefprotogetter= ' ~/.vim/bundle/protodef/pullproto.pl '
member function is consistent with the declaration order Let
g:disable_protodef_sorting=1
When used, first in the source directory using the ctags-r command to generate tags file; Then declare the class function in the. h file, switch to the same. cpp file, and type <LEADER>PP to complement the full function blank body
Content Lookup
Https://github.com/dyng/ctrlsf.vim
Need to install ACK beforehand
sudo apt-get install Ack-grep
Install AG
sudo apt-get install Silversearcher-ag
Https://github.com/rking/ag.vim
Add the following configuration to the. VIMRC
"Use the Ctrlsf.vim plug-in to globally find the cursor location keyword in the project and set the shortcut key. Shortcuts shorthand: Search in Project
nnoremap <leader>sp:CtrlSF<CR>
Noremap <leader>? : Ctrlsf-r
Nmap <F4>:ctrlsftoggle<cr>
Noremap <leader>/: Silent Execute ("Ctrlsf-r ' \\b". Expand ("<cword>"). "\\b '") <CR>
Let G:CTRLSF_ACKPRG = ' AG ' Set CTRLSF using AG
"AG shortcut keys
Noremap <leader>f:silent Execute ("Ag". Expand ("<cword>")) <CR>
Grammar detection
Https://github.com/scrooloose/syntastic
Add the following configuration to the. VIMRC
Let G:syntastic_error_symbol = ' ✗ '
Let G:syntastic_warning_symbol = ' ⚠ '
"Whether to check when opening files
Let G:syntastic_check_on_open=0
"Whether to check after saving files
Let G:syntastic_check_on_wq=1
Content substitution
Add the full configuration information into the. VIMRC:
"Replace function. Parameter description:
"confirm: whether to confirm one by one before replacing
"wholeword: whether the whole word matches
"replace: replaced string
function! Replace (confirm, wholeword, replace)
wa
let flag = ''
if a: confirm
let flag. = 'gec'
else
let flag. = 'ge'
endif
let search = ''
if a: wholeword
let search. = '\ <'. escape (expand ('<cword>'), '/\.*$^ ~ ['). '\>'
else
let search. = expand ('<cword>')
endif
let replace = escape (a: replace, '/ \ & ~')
execute 'argdo% s /'. search. '/'. replace. '/'. flag. '| update'
endfunction
"Unconfirmed, not whole word
"nnoremap <Leader> R: call Replace (0, 0, input ('Replace' .expand ('<cword>'). 'with:')) <CR>
"Unconfirmed, whole word
nnoremap <Leader> rw: call Replace (0, 1, input ('Replace' .expand ('<cword>'). 'with:')) <CR>
"Confirmation
"nnoremap <Leader> rc: call Replace (1, 0, input ('Replace' .expand ('<cword>'). 'with:')) <CR>
"Confirmation, whole word
"nnoremap <Leader> rcw: call Replace (1, 1, input ('Replace' .expand ('<cword>'). 'with:')) <CR>
"nnoremap <Leader> rwc: call Replace (1, 1, input ('Replace' .expand ('<cword>'). 'with:')) <CR>
File Lookup
Https://github.com/Yggdroot/LeaderF
Modify the plugin source code, change the shortcut key to comply with personal action modification
In leaderf/python/leaderf/cli.py
Note the following 4 lines of code
elif equal (cmd, ' <C-V> ') or equal (cmd, ' <S-Insert> '):
Self._paste ()
Self._buildpattern ()
Yield ' <Update> '
In the following line of code
elif equal (cmd, ' <C-C> '):
Yield ' <Quit> '
Add the following two lines of code later
elif equal (cmd, ' <C-P> '):
Yield ' <Quit> '
In leaderf/python/leaderf/manager.py
Modify Elif equal (cmd, ' <C-]> '): For elif equal (cmd, ' <C-V> '):
Add the following configuration in. vimrc
Let G:lf_shortcutf = ' <C-P> '
Let G:lf_commandmap = {' <C-C> ': [' <Esc> ', ' <C-C> ']}
Nmap <leader>m:LeaderfMru<CR>
IMAP <c-p> <ESC>:LeaderfFile<CR>
View function, struct, variable list
Https://github.com/majutsushi/tagbar
"Sets the width of the label child window
Let tagbar_width=32
"Redundant help information is not displayed in the Tagbar child window
Let G:tagbar_compact=1
Go language Configuration
Let G:tagbar_type_go = {
\ ' Ctagstype ': ' Go ',
\ ' Kinds ': [
\ ' P:package ',
\ ' I:imports:1 ',
\ ' C:constants ',
\ ' V:variables ',
\ ' T:types ',
\ ' N:interfaces ',
\ ' W:fields ',
\ ' e:embedded ',
\ ' M:methods ',
\ ' R:constructor ',
\ ' F:functions '
\ ],
\ ' SRO ': '. ',
\ ' Kind2scope ': {
\ ' t ': ' CType ',
\ ' n ': ' Ntype '
\ },
\ ' Scope2kind ': {
\ ' CType ': ' t ',
\ ' ntype ': ' N '
\ },
\ ' Ctagsbin ': ' Gotags ',
\ ' Ctagsargs ': '-sort-silent '
\ }
C + + language configuration
"Set ctags which code elements to generate labels
Let g:tagbar_type_cpp = {\ ' kinds ': [
\ ' D:macros:1 ',
\ ' G:enums ',
\ ' t:typedefs:0:0 ',
\ ' e:enumerators:0:0 ',
\ ' N:namespaces ',
\ ' C:classes ',
\ ' S:structs ',
\ ' U:unions ',
\ ' F:functions ',
\ ' m:members:0:0 ',
\ ' v:global:0:0 ',
\ ' x:external:0:0 ',
\ ' l:local:0:0 '
\ ],
\ ' SRO ': ':: ',
\ ' Kind2scope ': {
\ ' G ': ' Enum ',
\ ' n ': ' Namespace ',
\ ' C ': ' Class ',
\ ' s ': ' struct ',
\ ' u ': ' Union '
\ },
\ ' Scope2kind ': {
\ ' enum ': ' G ',
\ ' namespace ': ' N ',
\ ' class ': ' C ',
\ ' struct ': ' s ',
\ ' Union ': ' U '
\ }
\ }
Nmap <F3>:tagbartoggle<cr>
Task List
Https://github.com/vim-scripts/TaskList.vim
This is a very useful plug-in, it can tag the files in the Fixme, TODO and other information, and put them into a task list, at any time can jump to these tags in the back of the tasklist to modify the code, is a very convenient and practical TODO list tool.
--help: Usually just add a map: Map <LEADER>TD <plug>tasklist
Multiple cursor input
Https://github.com/terryma/vim-multiple-cursors
In normal mode, press Ctrl-n to start into the visual mode and select the words under the cursor, continue to press Ctrl-n to select the next same word, press Ctrl-p to choose one back, ctrl-x skip the next same word. Press C for modification, press <Esc> exit
Status Bar Landscaping
Https://github.com/itchyny/lightline.vim
or Vim-airline.
See
http://blog.csdn.net/the_victory/article/details/50638810
"--------------------------------------------------------------------------
"Vim-airline
"--------------------------------------------------------------------------
Plugin ' Vim-airline '
Let G:airline_theme= "Molokai"
"This is a font that must be set after you install it."
Let g:airline_powerline_fonts = 1
"Close status display blank symbol count"
Let g:airline#extensions#whitespace#enabled = 0
Let G:airline#extensions#whitespace#symbol = '! '
If!exists (' G:airline_symbols ')
Let G:airline_symbols = {}
endif
"Displays the absolute path of the file on the status bar of the airline
Let G:airline_section_c = "%{expand ('%:p ')}"
The integrated shell in vim
Conque "Support for Chinese is problematic
http://www.vim.org/scripts/script.php?script_id=2771
Usage Instructions Https://code.google.com/archive/p/conque/wikis/Usage.wiki#3.1.8_Hide_start_messages
Nmap <leader>sh:conquetermvsplit bash<cr>
Let g:conqueterm_pyversion = 2 "The native Python is 2.7, so this is set to 2
Let G:conqueterm_startmessages = 0 "get rid of annoying warnings
Automatic formatting of code
Https://github.com/sbdchd/neoformat
Need to install Astyle, http://astyle.sourceforge.net/
Parameter configuration for Astyle see
http://blog.csdn.net/janepen/article/details/7022180
Http://blog.chinaunix.net/uid-20662363-id-1904145.html
In Neoformat/auto/load/neoformat/formatters, edit Cpp.vim and C.vim separately as follows
Cpp.vim
function! neoformat#formatters#cpp#enabled () abort
return [' Astyle ']
Endfunction
function! neoformat#formatters#cpp#astyle () Abort
Return {
\ ' exe: ' Astyle ',
\ ' args ': ['--style=allman ', '-p ', '-d ', '--pa D-header '],
\ ' stdin ': 1,
\}
E Ndfunction
C.vim
function! neoformat#formatters#c#enabled () abort
return [' Astyle ']
Endfunction
function! neoformat#formatters#c#astyle () Abort
return {
\ ' exe ': ' Astyle ',
\ ' args ': ['--mode=c ', ' --style=allman ', ' P ', ' d ', '--pad-header '],
\ ' stdin ': 1,
\}
Endfunction
The following configuration is written in. vimrc
Augroup FMT
autocmd!
Autocmd Bufwritepre * undojoin | Neoformat
Augroup End
Automatically save
Https://github.com/vim-scripts/vim-auto-save "====================================================== Vim-auto-save Let G:auto_save = 1 "Set the UpdateTime value immutable, the default of" Let G:auto_save_no_updatetime = 1 "Let G:updatetime = 50 "Do not save automatically in insert mode let G:auto_save_in_insert_mode = 0" Save time is not prompted to save the status bar "Let G:auto_save_silent = 1
Smooth scrolling
Https://github.com/yuttie/comfortable-motion.vim
Quick edit pairs of parentheses
Https://github.com/tpope/vim-surround in normal mode, DS (or DS) deletes a pair of parentheses, DS "deletes a pair of double quotes, DS ' deletes a pair of single quotes, ds[(or DS]) deletes a pair of brackets, ds{(or D s}) Delete a pair of braces Cs "(is to replace a pair of" (
Quick Selection
Https://github.com/terryma/vim-expand-region "====================================================== Vim-expand-region Vmap v <Plug> (expand_region_expand) vmap <C-v> <Plug> (Expand_region_shrink)
Match Bracket
Https://github.com/vim-scripts/matchit.zip
C + + grammar check
Https://github.com/w0rp/ale
Need to install Cppcheck:sudo apt install cppcheck reference http://blog.csdn.net/demorngel/article/details/69052789 "================= ===================================== Ale
Let G:ale_set_loclist = 0
Let G:ale_open_list = 1
Let G:ale_keep_list_window_open = 1
The custom error and warning icons
Let G:ale_sign_error = ' ✗ '
Let g:ale_sign_warning = ' ⚡ '
"Combine the ale with the Vim's own status bar
Let G:ale_statusline_format = [' ✗%d ', ' ⚡%d ', ' ✔ok ']
"Displays Linter name, error, or warning, and other related information
Let g:ale_echo_msg_error_str = ' E '
Let g:ale_echo_msg_warning_str = ' W '
Let G:ale_echo_msg_format = ' [%linter%]%s [%severity%] '
In normal mode, the SP goes to the previous error or warning, SN goes to the next error or warning
Nmap sp <Plug> (ale_previous_wrap)
Nmap SN <Plug> (ale_next_wrap)
"<leader>d View details of an error or warning
Nmap <Leader>d:ALEDetail<CR>
"Set what the status bar displays
"Set statusline=%f%m%r%h%w\ [format=%{&ff}]\ [type=%y]\ [pos=%l,%v][%p%%]\%{strftime (\%d/%m/%y\-\%H:%M\")}\%{ Alegetstatusline ()}
"Do not check when the contents of the file are changed
"Let g:ale_lint_on_text_changed = ' Never '
"Do not check when opening a file
"Let G:ale_lint_on_enter = 0
"To use Clang for C + + + syntax checking
"Let g:ale_linters = {' c ': ' Clang '}"
"Let g:ale_c_clang_options = '-std=c11-wall '
"Let g:ale_linters = {' c + + ': ' clang++ '}"
Let g:ale_cpp_clangcheck_options = '-std=c++11-wall '
Let g:ale_cpp_gcc_options = '-std=c++11-wall '
"Turn off Golang syntax detection
"Let G:ale_linters = {' Go ': [' gofmt ']}
Let g:ale_linters = {
\ ' C ': [' clang '],
\ C + +: [' clang++ '],
\ "Go": [' Go builds ', ' gofmt ', ' Go Vet ']
\}
"Open Golang Syntax detection
"Let G:ale_linters = {' Go ': [' gometalinter ', ' gofmt ']}
Vim-go
"====================================================== vim-go Configuration
Let G:go_disable_autoinstall = 0 "Prohibit automatic download
Let g:go_highlight_functions = 1
Let G:go_highlight_methods = 1
Let G:go_highlight_fields = 1
Let G:go_highlight_types = 1
Let g:go_highlight_operators = 1
Let g:go_highlight_build_constraints = 1
Let G:go_auto_type_info = 1
Let G:go_fmt_command = "Goimports"
Let G:go_metalinter_autosave = 0
Au FileType go nmap <F12> <Plug> (go-def)
Au FileType go nmap <F5> <Plug> (Go-run)
Au FileType go nmap <leader>b <Plug> (go-build)
Au FileType go nmap <leader>e <Plug> (go-rename)
Au FileType go nmap <leader>gd <Plug> (Go-doc)
Au FileType go nmap <leader>s <Plug> (go-implements)
Au FileType go nmap <leader>r <Plug> (go-referrers)
"Au FileType go nmap <leader>t <Plug> (Go-vet)