https://github.com/dos5gw/vimrc
" F1 list tags " F2 open quickfix | Shift-F2 close quickfix " F3 list buffers " F4 nerd-tree " F5 exec grep.vim | Shift-F5 GrepOptions " F6 exec vimgrep " F8 none " F10 attach tags | Shift-F10 generate tags " F12 toggle mini-buf-expl " ---------------------------------------------- " General { " Basic set nocompatible " be iMproved filetype plugin indent on " automatically detect file types. syntax enable " syntax highlight set autochdir " always switch to the current file directory set cscopeverbose " show tips when adding cscope database set history=50 " keep 50 lines of command line history set mouse=a " enable mouse in GUI mode set number " show line numbers set ruler " show cursor position all the time " UI colorscheme molokai "colorscheme phd set background=dark set t_Co=256 "set cursorline " hight current line set guioptions-=m " remove menu bar set guioptions-=T " remove toolbar set laststatus=2 " always show status line. set showcmd " display an incomplete command in statusline set wildmenu " show list instead of just completing " Fonts if has("gui_gtk2") "set guifont=Droid\ Sans\ Mono\ 11 set guifont=CosmicSansNeueMono\ 13 elseif has("gui_win32") set guifont=Consolas:h11:cANSI endif " Encoding set encoding=utf-8 set fileencodings=utf-8,gb2312,gbk,gb18030 set backspace=indent,eol,start " allow backspacing over everything in insert mode " Indent set autoindent " preserve current indent on new lines set cindent " set C style indent " Fold set foldenable " turn on folding "set foldmethod=manual " zo and zf% set foldmethod=syntax " zo and zc set foldlevelstart=99 " no fold by default " Buffer set autoread " auto reload modified files set autowrite " auto write unsaved buffers set hidden " current buffer can be put to the background without writing to disk " Searching set hlsearch " highlight search terms set incsearch " find as you type search set nowrapscan " disable search loop set showmatch " show matching brackets/parenthesis "set ignorecase " case sensitive " Tab and wrap "set nowrap " wrap long lines set expandtab " convert all tabs typed to spaces set tabstop=4 " indentation levels every four columns set shiftwidth=4 " indent/outdent by four columns set shiftround " indent/outdent to nearest tabstop set smarttab " be smart when using tabs ;) " Exclude files and directories set wildignore+=*.swp,*.zip,*.rar,*.gz,*.o,*.so,*.a,*.bin,*.dat,*.map,*.out,cscope.*,*/.svn/*,tags " } set rtp+=~/.vim/bundle/vundle/ call vundle#rc() Bundle 'gmarik/vundle' " vundle plugins: { " original repos on GitHub { Bundle 'kien/ctrlp.vim' Bundle 'Lokaltog/vim-easymotion' Bundle 'Lokaltog/vim-powerline' Bundle 'mileszs/ack.vim' Bundle 'Valloric/YouCompleteMe' " } " vim-scripts repos { Bundle 'bufexplorer.zip' "Bundle 'c.vim' "Bundle 'Conque-Shell' Bundle 'echofunc.vim' Bundle 'EasyGrep' Bundle 'grep.vim' Bundle 'snipMate' "Bundle 'SuperTab' Bundle 'TabBar' Bundle 'taglist.vim' Bundle 'The-NERD-tree' "Bundle 'Vimpress' Bundle 'Markdown' " } " } " Brief help { " :BundleList - list configured bundles " :BundleInstall(!) - install(update) bundles " :BundleSearch(!) foo - search(or refresh cache first) for foo " :BundleClean(!) - confirm(or auto-approve) removal of unused bundles " } " Key mapping { " Key for Generic{ " Copy & Paste & Cut vmap <C-Insert> "+y vmap <M-Insert> "+c vmap <S-Insert> c<ESC>"+p imap <S-Insert> <C-r><C-o>+ nmap <S-Insert> "+p vmap <C-c> "+y vmap <C-x> "+c vmap <C-v> c<ESC>"+p imap <C-v> <C-r><C-o>+ nmap <C-v> "+p " Visual block mode noremap vv <C-v> " Smart way to move between windows map <C-j> <C-W>j map <C-k> <C-W>k map <C-h> <C-W>h map <C-l> <C-W>l " Switch buffers like chrome:) noremap <C-PageUp> :bp<CR> noremap <C-PageDown> :bn<CR> " Useful mappings for managing tabs map <leader>tn :tabnew<cr> map <leader>to :tabonly<cr> map <leader>tc :tabclose<cr> map <leader>tm :tabmove " Switch CWD to the directory of the open buffer map <leader>cd :cd %:p:h<cr>:pwd<cr> " Swtich ignore up and lowercase map <leader><leader>i :set ignorecase<cr> map <leader><leader>I :set noignorecase<cr> " Use SPACE to open and close fold, fdm must be set as syntax nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR> " Move a line of text using ALT+[jk] or Comamnd+[jk] on mac nmap <M-j> mz:m+<cr>`z nmap <M-k> mz:m-2<cr>`z vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z " -- Auto generate &attach tags -- nmap <F10> :call AttachTags()<CR> nmap <S-F10> :call GenerateTags()<CR> " } " Key for Plugins { noremap <F1> :Tlist<CR> noremap <F2> :botright copen<cr> noremap <S-F2> :cclose<cr> noremap <F3> :BufExplorer<cr> noremap <F4> :NERDTreeToggle<cr> noremap <F5> :Rgrep<CR> noremap <S-F5> :GrepOptions<CR> noremap <F6> :execute "vimgrep /" . expand("<cword>") . "/j **/*.c **/*.h" <Bar> cw<CR> noremap <F11> :call Sdk() noremap <F12> :TMiniBufExplorer<cr> nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR> nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR> nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR> nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR> nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR> nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR> nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR> nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR> nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR> " } " } " Plugin { " plugin::grep.vim { let Grep_Default_Options = '-i' let Grep_Default_Filelist = '*.c *.cpp *.h' let Grep_Skip_Dirs = '.svn obj CVS' let Grep_Skip_Files = 'tags *~ cscope.* *.a *.o *.bak' " } " plugin::taglist { let Tlist_Auto_Open = 1 let Tlist_Exit_OnlyWindow = 1 let Tlist_Show_One_File = 1 let Tlist_Sort_Type = "name" let Tlist_Use_Right_Window = 0 let Tlist_WinWidth = 30 " } " plugin::nerdtree { let g:NERDTreeWinPos="right" let NERDChristmasTree=1 let NERDTreeChDirMode=1 let NERDTreeIgnore=['\.o$', '\.ko$', '\~$', '\.dir$'] " } " plugin::ctrlp { " [set autochdir] would auto change dir with NERDTree " create file '_ctrlp' to mark root directory let g:ctrlp_root_markers = ['_ctrlp'] let g:ctrlp_cmd = 'CtrlP' let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$\|.rvm$|.dir$' let g:ctrlp_follow_symlinks=1 let g:ctrlp_map = '<c-p>' let g:ctrlp_match_window_bottom=1 let g:ctrlp_match_window_reversed=0 let g:ctrlp_max_height=15 let g:ctrlp_mruf_max=500 "} " plugin::powerline { "let Powerline_symbols = 'compatible' "let g:Powerline_symbols = 'fancy' " } " plugin::YouCompleteMe { let g:ycm_global_ycm_extra_conf = '~/.vim/raw/ycm_extra_conf.py' let g:ycm_min_num_of_chars_for_completion = 5 let g:ycm_semantic_triggers = { \ 'c' : ['->', '.'], \ 'objc' : ['->', '.'], \ 'cpp,objcpp' : ['->', '.', '::'], \ 'cs,java,javascript,d,vim,python,perl6,scala,vb,elixir,go' : ['.'], \ } " } " plugin::TabBar { let g:Tb_MaxSize = 2 let g:Tb_TabWrap = 1 " } " } function GenerateTags() silent! execute "!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ." if(executable('cscope') && has("cscope")) silent! execute "!find -L `pwd` -name '*.h' -o -name '*.c' -o -name '*.cpp' > cscope.files" endif silent! execute "!cscope -bq" endf function AttachTags() if filereadable("cscope.out") execute "cs add cscope.out" execute "set tags+=./tags" endif endf silent! execute "call AttachTags()" " ctags -R -f ~/.vim/raw/systags --c-kinds=+p --c++-kinds=+px --fields=+iaS --extra=+q --python-kinds=-i /usr/include /usr/local/include " set tags+=~/.vim/raw/systags " VIMRC END