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 "+y
vmap "+c
vmap c"+p
imap +
nmap "+p
vmap "+y
vmap "+c
vmap c"+p
imap +
nmap "+p
" Visual block mode
noremap vv
" Smart way to move between windows
map j
map k
map h
map l
" Switch buffers like chrome:)
noremap :bp
noremap :bn
" Useful mappings for managing tabs
map tn :tabnew
map to :tabonly
map tc :tabclose
map tm :tabmove
" Switch CWD to the directory of the open buffer
map cd :cd %:p:h:pwd
" Swtich ignore up and lowercase
map i :set ignorecase
map I :set noignorecase
" Use SPACE to open and close fold, fdm must be set as syntax
nnoremap @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')
" Move a line of text using ALT+[jk] or Comamnd+[jk] on mac
nmap mz:m+`z
nmap mz:m-2`z
vmap :m'>+`mzgv`yo`z
vmap :m'<-2`>my` :call AttachTags()
nmap :call GenerateTags()
" }
" Key for Plugins {
noremap :Tlist
noremap :botright copen
noremap :cclose
noremap :BufExplorer
noremap :NERDTreeToggle
noremap :Rgrep
noremap :GrepOptions
noremap :execute "vimgrep /" . expand("") . "/j **/*.c **/*.h" cw
noremap :call Sdk()
noremap :TMiniBufExplorer
nnoremap jd :YcmCompleter GoToDefinitionElseDeclaration
nmap s :cs find s =expand("")
nmap g :cs find g =expand("")
nmap c :cs find c =expand("")
nmap t :cs find t =expand("")
nmap e :cs find e =expand("")
nmap f :cs find f =expand("")
nmap i :cs find i ^=expand("")$
nmap d :cs find d =expand("")
" }
" }
" 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 = ''
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