Vim Plugin and configuration

Source: Internet
Author: User
Tags imap set background python script

Vim plugin and configuration plugin pathogen can easily manage vim plugins

In the absence of pathogen, Vim plugin files are all placed in the. Vim directory, uninstall plug-ins is troublesome, pathogen can put different plugins in a separate directory, install plug-ins only need to copy the plugin folder into the development folder (bundle), uninstall the plugin only need to delete folders, easy to use.

The following plugins can be installed using the "Download Zip package to Vundle folder, unzip the Zip package" method

Download and install Https://github.com/tpope/vim-pathogen

Nerdtree for viewing the directory tree

Download Https://github.com/scrooloose/nerdtree

Tabular for formatting code

Download Https://github.com/godlygeek/tabular

Tagbar View Code structure

Download Https://github.com/majutsushi/tagbar

Airline for setting vim themes

Download Https://github.com/bling/vim-airline

Molokai for setting Vim themes

Download Https://github.com/tomasr/molokai

MRU Save recently opened file

Download Https://github.com/vim-scripts/mru.vim

Easymotion for searching

Download https://github.com/easymotion/vim-easymotion

CTRLP Powerful Search Plugin

Download Https://github.com/kien/ctrlp.vim

Autocomplpop for auto-completion

Download Https://github.com/vim-scripts/AutoComplPop

Omnicppcomplete for auto-completion

Download Https://github.com/vim-scripts/OmniCppComplete

Configure Basic configuration key Mapping

The key mapping configuration is written in. VIMRC,. VIMRC in the home directory

imap jk <ESC\>              " 按jk退出编辑状态,再也不用小指头按Esc了map wq <ESC>:wq<CR>         " 按wq就直接保存退出imap wq <ESC>:wq<CR>        " 按wq就直接保存退出map qq <ESC>:q!<CR>         " 按qq就直接不保存退出imap qq <ESC>:q!<CR>        " 按qq就直接不保存退出map <F2> <ESC><C-W><C-W>    " 按F2进行窗口切换,不按<C-W><C-W>map <F3> <ESC>:Tagbar<CR>   " 按F3打开代码结构map <F4> <ESC>:NERDTreeToggle<CR>map <F12> <ESC>:!ctags -R --c++-kinds=+px --fields=+aiKSz --extra=+q .<CR>  " 按F12生成tag
CTRLP Key Mapping
map ,pp <ESC>:CtrlP<CR>             "搜索文件map ,pd <ESC>:CtrlPDir<CR>          "搜索文件夹map ,pu <ESC>:CtrlPUndo<CR>         "搜索修改记录,可以回退map ,pl <ESC>:CtrlPLine<CR>         "搜索行map ,pc <ESC>:CtrlPChangeAll<CR>    "搜索修改记录,可以定位光标map ,pm <ESC>:CtrlPMRU<CR>          "搜索最近修改的文件
Complement the whole

Auto-completion in Vim is cumbersome, but writing code without auto-completion is completely unacceptable. In order to achieve automatic completion, I started using Omnicppcomplete and Autocomplpop, and later heard that there is a cool plug-in called Youcompleteme, can be parsed, to achieve automatic completion, so I went to try. Our development machine can not access the external network, or directly under the root user directly installed software, installation Youcompleteme really troublesome. I have compiled with the source code installed CMake, LLVM, Python, vim and Youcompleteme, spent a lot of time, and finally put the youcompleteme installed, but when used, complete or not enough intelligence, not as good as imagined. Later moved to the new development machine, do not want to reinstall Youcompleteme, back to Omnicppcomplete and Autocomplpop. Finally, I found that omnicppcomplete and autocomplpop achieve better completion than Youcompleteme. Almost every VIM user will face the function of auto-completion, here, I suggest using omnicppcomplete and autocomplpop combination, simple and convenient, good effect.

Because the project was compiled using blade build, build records the dependencies of the project, so I wrote a Python script to parse the build file, get the corresponding dependencies, and then build the tag based on the dependency to improve the code completion ability. Finally, Vim's code completion ability is also good! Here's how to use it:

    1. Installing Ctags, Omnicppcomplete, and Autocomplpop
    2. Add a line of configuration to vim: set Tags+=./deps_tags
    3. Run the deps_tag.py script in the directory where the build resides, generating deps_tags based on dependencies
    4. Tags for cost-per-F12 projects
    5. Happy to use complement
    6. This can actually be done every time you save the file automatically regenerate tags, but because tags are based on the working path, if not in the project path will generate unnecessary tags
Finally, please use my vim configuration
"Set Codingset termencoding=utf-8set encoding=utf-8set fileencoding=utf-8set fenc=utf-8 set Fencs=utf-8,usc-bom, euc-jp,gb18030,gbk,gb2312,cp936 set Backspace=indent,eol,startset nocompatible "be improved, Requiredset m Ouse=a "Mouse usefulset nu" set Numberset NOCP set n Obackup "No backupset noerrorbells" no Voiceset showmatch "show mat Ch of () {} []set ignorecase ' ignore case in Searchset cursorline ' Hightlight current Lineset cursorcolumn "Hightlight collum" set autochdir "Auto Change Dirset autoin                   Dent "Autoindent is auto indent, cindent is specifically for the C language Syntax auto indent set smartindent set cindent set tabstop=4                 The tab is 4 set softtabstop=4 set shiftwidth=4 set scrolloff=3 "The cursor moves to the top and bottom of the buffer while maintaining 3 lines of distance set cmdheight=2 The height of the command line (under the status line), which defaults to1, here is 2set statusline=%f%m%r%h%w[%p%%] "My status line shows the contents set laststatus=2" Always show the status line syntax on "Syntax highlighting" key Mapimap JK <ESC> "Press JK to exit Edit Status map Wq <esc>:wq<cr>imap Wq <esc>:wq&lt ; Cr>map QQ <esc>:q!<cr>imap QQ <esc>:q!<cr>map CP <esc>:set Mouse=c<CR>:set Nonu <cr>map NCP <esc>:set Mouse=a<cr>:set Nu<cr>map, PA <esc>:set paste<CR>map, NP < Esc>:set nopaste<cr>map gn <esc>:tabnext<cr>map GM <esc><c-w><c-w>map <F2 > <esc><c-w><c-w>map <F3> <esc>:tagbar<cr>map <F4> <esc>: Nerdtreetoggle<cr>map <F12> <esc>:!ctags-r--c++-kinds=+px--fields=+aiksz--extra=+q .<CR> " Pathogenfiletype off "Requiredcall pathogen#infect () filetype plugin on" Themesyntax enableset t_co=256l ET g:airline_theme= "dark" set Background=darkcolorscheme Molokai "Let G:autoopenwinmanager = 1let g:nerdtreedirarrows = 1let G:nerdtree_tabs_autoclose = 0let g:bufexplorersplitve Rtsize = 30let G:bufexplorermaxheight=30let g:winmanagerwindowlayout = "fileexplorer| Bufexplorer "Let G:winmanagerwidth =" Easymotionmap/<Plug> (EASYMOTION-SN) omap/<Plug> (EASYMOTION-TN) Map n <Plug> (easymotion-next) map n <Plug> (easymotion-prev) map <leader>l <Plug> ( Easymotion-lineforward) Map <leader>j <Plug> (easymotion-j) Map <leader>k <Plug> (easymotion-k ) Map <leader>h <Plug> (easymotion-linebackward) Let G:easymotion_use_upper = 1 "Use uppercase target L Abels and type as a lower caselet g:easymotion_smartcase = 1 "type ' l ' and Match ' l ' & ' l ' let g:easymotion_use _smartsign_us = 1 "smartsign (type ' 3 ' and Match ' 3 ' & ' # ')" Easygreplet G:easygrepmode = 2 "all:0, Open buffers:1, trackext:2 "Let G:easygrepcommand = 0" Use vimgrep:0, grepprg:1Let g:easygreprecursive = 1 "Recursive searchinglet g:easygrepignorecase = 1" Not Ignorecase:0let G:easygrepfilestoexclude = "*.bak, *~, cscope.*, *.a, *.O, *.pyc, *.bak" "Let G:easygrepopenwindowonmatch = 0" Ctrlplet g:c Trlp_by_filename = 1let G:ctrlp_working_path_mode = ' 0 ' "let G:ctrlp_cmd = ' ctrlpmixed ' let G:ctrlp_match_window = ' bottom, Order:ttb,min:1,max:10,results:20 ' "Let G:ctrlp_regexp = 0let g:ctrlp_extensions = [' Buffertag ', ' dir ', ' undo ', ' line ', ' Changes ', ' mixed ', ' Bookmarkdir ']map, pp <esc>:ctrlp<cr>map, PD <esc>:ctrlpdir<cr>map, Pu < Esc>:ctrlpundo<cr>map, pl <esc>:ctrlpline<cr>map, PC <esc>:ctrlpchangeall<cr>map, PB <esc>:ctrlpbookmarkdir<cr>map, PM <ESC>:CtrlPMRU<CR> "acplet g:acp_enableatstartup = 1let g : Acp_completeoptpreview = 0let G:acp_ignorecaseoption = 1let G:acp_behaviorkeywordcommand = "\<c-p>" Let G:acp_ Behaviorkeywordlength = 1 "Omnicppcomplete Let OMNIcpp_maycompletedot = 1 "autocomplete with. Let Omnicpp_maycompletearrow = 1" autocomplete with->let omnicpp _maycompletescope = 1 "autocomplete with:: Let Omnicpp_selectfirstitem = 2" Select First Itemlet Omnicpp_namespac Esearch = 2 "Search namespaces in this and included fileslet OMNICPP_SHOWPROTOTYPEINABBR = 1" show function Prototyp  E in Popup windowlet omnicpp_globalscopesearch=1 "enable the global scope Searchlet omnicpp_displaymode=1" Class scope Completion mode:always Show all Memberslet omnicpp_defaultnamespaces=["Std"] "au cursormovedi,insertleave * If pumvisible () = = 0|silent! Pclose|endif "Auto-close full window set Completeopt=menu,longestset tags+=./deps_tags

Vim plug-ins and configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.