最近爱上了vim, 喜欢它超灵活的扩展性。以下是我的.vimrc配置文件:
:let mapleader = "," set nu set ts=4 sw=4 expandtab smartindent nohlsearch number incsearch showmatch set bs=2 set laststatus=2 "set cursorline set autoread nmap <leader>a :set mouse=a<CR> nmap <leader>d :set mouse=<CR> nmap <F9> :source ~/.vimrc<CR> nmap <leader>fn :echo expand('%')<CR> "set foldmethod=syntax nmap <C-Tab> <C-K><Tab> call pathogen#infect() set path = "./" set path += "/usr/include/c++" "ctags={ set tags+=./tags set tags+=~/.vim/tags/cpp " build tags of your own project with Ctrl-F12 map <C-F12> :!ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q .<CR> "} "supertab{ let g:SuperTabRetainCompletionType=2 let g:SuperTabDefaultCompletionType="<C-X><C-O>" "} " "winmanager{ let g:winManagerWindowLayout='FileExplorer|TagList' nmap wm :WMToggle<cr> "} "powerline{ set guifont=PowerlineSymbols\ for\ Powerline set nocompatible set t_Co=256 let g:Powerline_symbols = 'fancy' "} "minibufexplorer{ let g:miniBufExplMapWindowNavVim = 1 let g:miniBufExplMapWindowNavArrows = 1 let g:miniBufExplMapCTabSwitchBufs = 1 let g:miniBufExplModSelTarget = 1 noremap <silent> <leader>f :call <SID>CycleBuffer(1)<CR>:<BS> noremap <silent> <leader>f :call <SID>CycleBuffer(0)<CR>:<BS> "} "taglist{ let Tlist_Show_One_File = 1 let Tlist_Exit_OnlyWindow = 1 let Tlist_Auto_Open = 0 nmap <F7> :Tlist<CR> "} "cscope{ :set cscopequickfix=s-,g-,c-,d-,i-,t-,e- :set nocscopeverbose " build tags of your own project with Ctrl-F12 map <C-F11> :!cscope -Rbq -s . -f cscope.out<CR> if filereadable("./cscope.out") :cs add ./cscope.out endif "Find this C symbol nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR> "Find this definition nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR> "Find functions calling this function nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR> "Find assignments to nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR> "Find this egrep pattern nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR> "Find this file nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR> "Find files #including this file nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR> "Find functions called by this function nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR> "} "tagbar{ nmap <F12> :TagbarToggle<CR> let g:tagbar_width = 22 "} " "OmniCppComplete{ set nocp filetype plugin on " OmniCppComplete let OmniCpp_NamespaceSearch = 1 let OmniCpp_GlobalScopeSearch = 1 let OmniCpp_ShowAccess = 1 let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters let OmniCpp_MayCompleteDot = 1 " autocomplete after . let OmniCpp_MayCompleteArrow = 1 " autocomplete after -> let OmniCpp_MayCompleteScope = 1 " autocomplete after :: let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"] " automatically open and close the popup menu / preview window au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif set completeopt=menuone,menu,longest,preview "} "a{ nnoremap <silent> <F4> :A<CR> "} " "NERDTree{ nnoremap <silent> <F2> :NERDTreeToggle<CR> nnoremap <silent> <C-t><C-f> :NERDTreeFind<CR> "} " "Grep{ nnoremap <silent> <F3> :Rgrep<CR> "} "} "SuperTab{ let g:SuperTabRetainCompletionType=2 let g:SuperTabDefaultCompletionType="<C-X><C-O>" "} "LookupFile{ map <C-F10> :!makelookuptag.sh<CR>:let g:LookupFile_TagExpr ='"./filenametags_lookupfile"'<CR> nnoremap <silent> <leader>lf :LookupFile<CR> "nnoremap <silent> <leader>lw :LUWalk<CR> "this function is not better than ,fd in FuzzyFinder "nnoremap <silent> <leader>lp :LUPath<CR> nnoremap <silent> <leader>lb :LUBufs<CR> let g:LookupFile_MinPatLength = 2 let g:LookupFile_PreserveLastPattern = 0 let g:LookupFile_PreservePatternHistory = 1 let g:LookupFile_AlwaysAcceptFirst = 1 let g:LookupFile_AllowNewFiles = 0 let g:LookupFile_ignorecase = 1 let g:LookupFile_smartcase = 1 let g:LookupFile_SortMethod = "" if filereadable("./filenametags_lookupfile") let g:LookupFile_TagExpr ='"./filenametags_lookupfile"' endif "} "FuzzyFinder{ "nnoremap <silent> <leader>ff :FufFile<CR> nnoremap <silent> <leader>fd :FufDir<CR> "} "ctrlp{ let g:ctrlp_cmd = 'CtrlP' set wildignore+=*/Build-vc90/*,*.o,*.exe,*.git,*.pdb,*.bak,*.so,*.a let g:ctrlp_by_filename = 1 " only lookup file name let g:ctrlp_max_height = 15 let g:ctrlp_clear_cache_on_exit = 0 let g:ctrlp_cache_dir = $HOME.'/.ctrlp/cache/' let g:ctrlp_working_path_mode = 'ra' let g:ctrlp_custom_ignore = { \ 'dir': '\v[\/]\.(git|hg|svn)$', \ 'file': '\v\.(exe|so|dll|bak|gds)$', \ 'link': 'SOME_BAD_SYMBOLIC_LINKS', \ } "let g:ctrlp_user_command = 'find %s -type f | grep -P "\.pl$|\.py$|\.lua$|\.xml$|\.sh$|\.mk$|\.h$|\.hh$|\.hpp$|\.c$|\.cc$|\.cpp$"' "}
安装的插件如下:
~/.vim
├── autoload
│ └── pathogen.vim
├── bundle
│ ├── a
│ ├── clang_complete
│ ├── ctrlp
│ ├── fuzzyfinder
│ ├── genutils
│ ├── grep
│ ├── l9
│ ├── lookupfile
│ ├── minibufexpl
│ ├── nerdtree
│ ├── supertab
│ ├── tagbar
│ ├── taglist
│ ├── vim-powerline
│ └── winmanager
└── tags
├── cpp
└── cpp_src