我的vimrc

" 设置编码
set encoding=utf-8
set langmenu=zh_CN.UTF-8 "set menu's language of gvim. no spaces beside '='
language messages zh_CN.utf-8

"   ---------------------- 系统自带设置 -------------------------
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin

set diffexpr=MyDiff()
function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let eq = ''
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      let cmd = '""' . $VIMRUNTIME . '\diff"'
      let eq = '"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction


"------------------- vim基础设置 --------------------------
set nu                    " 显示行号
set hlsearch              " 高亮显示搜索结果
set tabstop=4             " tab键占4空格
set expandtab             " 用空格字符代替tab键
set cindent shiftwidth=4  " c语言缩进,缩进占4空格
set hidden                " 避免当前编辑文档未保存时,在新窗口打开文档
set ignorecase            " 搜索时不区分大小写
set cursorline            " 高亮光标所在行
set textwidth=80          "
set colorcolumn=+1        " 高亮指定列(编辑器中显示右边线)
set mouse=a               " 使用鼠标
set completeopt=menu      " 补全设置
"set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)
set nobackup
set laststatus=2          " 始终显示状态栏
set nowrap                " 不拆行
"set syntax enable
if has("gui_running")   "如果在 GUI 环境下运行则设置下面语句 
    set guifont=Consolas:h11
    set guioptions-=T   " 不显示工具栏
    set guioptions-=L   " 不显示左边滚动条
    set guioptions-=r   " 不显示右边滚动条
    set guioptions-=m 
    set vb t_vb=        " 禁用响铃提醒
    au GuiEnter * set t_vb=
    hi SpecialKey guifg=BG   " 让一些特殊的字符与背景色相同,比如讨厌的^M
endif


" --------------------------设置 常用快捷键--------------------------------
nmap ;h <c-w><c-h>
nmap ;j <c-w><c-j>
nmap ;k <c-w><c-k>
nmap ;l <c-w><c-l>
nmap Q :NERDTreeClose<CR>:TagbarClose<CR>:bwipe<CR>
nmap ;e $
nmap ;b 0
nmap <leader>q :q<CR>
nmap <leader>b :ls<CR>
nmap <leader>w :update<CR>
nmap <leader>e :browse confirm e<CR>
nmap <leader>s :e $VIM/_vimrc<CR>
nmap <C-D>M :set guioptions+=m<CR>
nmap <C-D>m :set guioptions-=m<CR>
nmap F <C-F>
nmap B <C-B>

nmap <C-Tab> <ESC>:b#<CR>
vmap <C-Tab> <ESC>:b#<CR>
imap <C-Tab> <ESC>:b#<CR>

nnoremap <F1> <ESC>:NERDTreeToggle<cr>
vnoremap <F1> <ESC>:NERDTreeToggle<cr>
inoremap <F1> <ESC>:NERDTreeToggle<cr>
nnoremap <F2> <ESC>:TagbarToggle<cr>
vnoremap <F2> <ESC>:TagbarToggle<cr>
inoremap <F2> <ESC>:TagbarToggle<cr>
vmap <F3>  <C-C><ESC>/<C-R>+<CR><ESC>
nmap <F3> <ESC>/<C-R>=expand("<cword>")<CR><CR>
imap <F3> <ESC>/<C-R>=expand("<cword>")<CR><CR>
" cpp和h文件的切换
nmap <F5> <ESC>:A<CR>
vmap <F5> <ESC>:A<CR>
imap <F5> <ESC>:A<CR>
nnoremap <silent> <F7> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/^/\/\/<CR>/^$x<CR>
vnoremap <silent> <F7> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/^/\/\/<CR>/^$x<CR>
inoremap <silent> <F7> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/^/\/\/<CR>/^$x<CR>
nnoremap <silent> <F8> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/\/\//<CR>/^$x<CR>
vnoremap <silent> <F8> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/\/\//<CR>/^$x<CR>
inoremap <silent> <F8> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/\/\//<CR>/^$x<CR>
nmap <F9> <ESC>:copen<CR><C-W>J
vmap <F9> <ESC>:copen<CR><C-W>J
imap <F9> <ESC>:copen<CR><C-W>J
nmap <F10> <ESC>:ccl<CR>
vmap <F10> <ESC>:ccl<CR>
imap <F10> <ESC>:ccl<CR>
nnoremap <F11> <ESC>:CtrlP<CR>
vnoremap <F11> <ESC>:CtrlP<CR>
inoremap <F11> <ESC>:CtrlP<CR>
nmap <F12> <ESC>:CtrlPBuffer<CR>
vmap <F12> <ESC>:CtrlPBuffer<CR>
imap <F12> <ESC>:CtrlPBuffer<CR>

" -----------------------------------插件快捷键-------------------------------------
nmap <C-D><C-D> :YcmCompleter GoToImprecise<CR>
vmap <C-D><C-D> <ESC>:YcmCompleter GoToImprecise<CR>
imap <C-D><C-D> <ESC>:YcmCompleter GoToImprecise<CR>
nmap <C-D><C-G> :YcmCompleter GoTo<CR>
vmap <C-D><C-G> <ESC>:YcmCompleter GoTo<CR>
imap <C-D><C-G> <ESC>:YcmCompleter GoTo<CR>
nmap <C-D><C-t> <ESC>:YcmCompleter GetType<CR>
vmap <C-D><C-t> <ESC>:YcmCompleter GetType<CR>
imap <C-D><C-t> <ESC>:YcmCompleter GetType<CR>
nmap <C-D><C-r> <ESC>:YcmRestartServer<CR>
vmap <C-D><C-r> <ESC>:YcmRestartServer<CR>
imap <C-D><C-r> <ESC>:YcmRestartServer<CR>
nmap <C-D><C-s> :YouCompleteMeStart<CR>

" -----------------------------------设置各插件-------------------------------------
" grep
let Grep_Find_Path = '"C:\Program Files\Git\usr\bin\find.exe"'
let Grep_Path = '"C:\Program Files\Git\usr\bin\grep.exe"'
let Grep_Xargs_Path = '"C:\Program Files\Git\usr\bin\xargs.exe"'
let Grep_Default_Options = '-i -r --include="*.cpp" --include="*.h" --include="*.hpp" --include="*.c" --include="*.cc"'
let Grep_Default_Filelist = '.'

" 设置Tagbar
let g:tagbar_left=1
let g:tagbar_width=30

" 设置 cscope
if has("cscope")
    set csprg=cscope
    set csto=0
    set cst
    set cscopequickfix=s-,g-,c-,f-,d-,i-,t-,e-
    set nocsverb
    set csverb
   nmap zs :cs find s <C-R>=expand("<cword>")<CR><CR>
    map <C-g><C-g> :cs find g <C-R>=expand("<cword>")<CR><CR>
    nmap <C-G><C-C> :cs find c <C-R>=expand("<cword>")<CR><CR>
    nmap <C-G><C-T> :cs find t <C-R>=expand("<cword>")<CR><CR>
    vmap <C-G><C-T> <ESC>:cs find t <C-R>=expand("<cword>")<CR><CR>
    imap <C-G><C-T> <ESC>:cs find t <C-R>=expand("<cword>")<CR><CR>
    nmap ze :cs find e <C-R>=expand("<cword>")<CR><CR>
    nmap <C-G><C-f> :cs find f <C-R>=expand("<cword>")<CR><CR>
    nmap zi :cs find i ^<C-R>=expand("<cword>")<CR>$<CR>
    nmap zd :cs find d <C-R>=expand("<cword>")<CR><CR>
endif

" 设置 ctrlp
let g:ctrlp_map = ''   " 去掉ctrl+p快捷键
"let g:ctrlp_reuse_window='netrw'
"let g:ctrlp_switch_buffer = 'Et'
"let g:ctrlp_open_new_file = 'r'
let g:ctrlp_by_filename = 1
let g:ctrlp_max_height = 15
let g:ctrlp_use_caching = 1
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_cache_dir = $VIM.'/cache/ctrlp'
" 手动指定搜索的根目录let g:ctrlp_root_markers = ['']

" Bundle
filetype off
" 设置vundle路径
set rtp+=$VIM/vimfiles/bundle/vundle/
call vundle#rc('$VIM/vimfiles/bundle/')  
Bundle 'gmarik/vundle'  
"Bundle 'Valloric/YouCompleteMe'
Bundle 'altercation/vim-colors-solarized'
Bundle 'Lokaltog/vim-powerline'
Bundle 'scrooloose/nerdtree'
Bundle 'vim-scripts/OmniCppComplete'
filetype plugin indent on  

"let g:ycm_global_ycm_extra_conf = $VIM.'/vimfiles/bundle/YouCompleteMe/python/.ycm_extra_conf.py'
"let g:ycm_confirm_extra_conf = 0 
"let g:ycm_show_diagnostics_ui = 0 
colorscheme solarized
let g:Powerline_colorscheme='solarized256'
let g:Powerline_stl_path_style = 'full'
let NERDTreeWinPos='right'

 一些插件的配置

"设置ctags快捷键
"map <F6> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR><CR> :TlistUpdate<CR>
"set tags=tags    "程序中跳转
"set autochdir

" 设置supertab
"let g:SuperTabDefaultCompletionType="context"

" grep
let Grep_Find_Path = '"C:\Program Files\Git\usr\bin\find.exe"'
let Grep_Path = '"C:\Program Files\Git\usr\bin\grep.exe"'
let Grep_Xargs_Path = '"C:\Program Files\Git\usr\bin\xargs.exe"'
let Grep_Default_Options = '-i -r --include="*.cpp" --include="*.h" --include="*.hpp" --include="*.c" --include="*.cc"'
let Grep_Default_Filelist = '.'
"let Grep_Default_Filelist .= ' D:\src\code\hes-ap-component\*.c D:\src\code\hes-ap-component\*.cpp D:\src\code\hes-ap-component\*.h *.hpp *.cc'

" 设置OmniCppComplete
"set nocp
"filetype plugin on
"let OmniCpp_MayCompleteDot = 1 " autocomplete with .
"let OmniCpp_MayCompleteArrow = 1 " autocomplete with ->
"let OmniCpp_MayCompleteScope = 1 " autocomplete with ::
"let OmniCpp_SelectFirstItem = 2 " select first item (but don't insert)
"let OmniCpp_NamespaceSearch = 2 " search namespaces in this and included files
"let OmniCpp_ShowPrototypeInAbbr = 1 " show function prototype in popup window
"let OmniCpp_GlobalScopeSearch=1 " enable the global scope search
"let OmniCpp_DisplayMode=1 " Class scope completion mode: always show all members
    "let OmniCpp_DefaultNamespaces=["std"]
"let OmniCpp_ShowScopeInAbbr=1 " show scope in abbreviation and remove the last column
"let OmniCpp_ShowAccess=1

" 设置TagList
"let Tlist_Show_One_File=1    "不同时显示多个文件的tag,只显示当前文件的
"let Tlist_Exit_OnlyWindow=1  "如果taglist窗口是最后一个窗口,则退出vim
"let Tlist_Use_Right_Window=1  "在右侧窗口中显示taglist窗口 (默认是0)
"let Tlist_Ctags_Cmd='ctags' "因为我们放在环境变量里,所以可以直接执行
"let Tlist_Inc_Winwidth=0
"let Tlist_WinWidth=20

" 设置Tagbar
let g:tagbar_left=1
let g:tagbar_width=30

" 设置WinManageer
"let g:winManagerWindowLayout='BufExplorer|FileExplorer|TagList'  
"let g:persistentBehaviour=0 " 如果所有编辑文件都关闭了,退出vim
"let g:bufExplorerMaxHeight=20 " 限制TagList的高度
" let g:AutoOpenWinManager = 1 " 启动时自动打开
"let g:winManagerWidth=30

" 设置easymotion
"map <Leader> <Plug>(easymotion-prefix)

" 设置 cscope
if has("cscope")
    set csprg=cscope
    set csto=0
    set cst
    set cscopequickfix=s-,g-,c-,f-,d-,i-,t-,e-
    set nocsverb
    set csverb
    nmap zs :cs find s <C-R>=expand("<cword>")<CR><CR>
    map <C-g><C-g> :cs find g <C-R>=expand("<cword>")<CR><CR>
    nmap zc :cs find c <C-R>=expand("<cword>")<CR><CR>
    nmap <C-G><C-T> :cs find t <C-R>=expand("<cword>")<CR><CR>
    vmap <C-G><C-T> <ESC>:cs find t <C-R>=expand("<cword>")<CR><CR>
    imap <C-G><C-T> <ESC>:cs find t <C-R>=expand("<cword>")<CR><CR>
    nmap ze :cs find e <C-R>=expand("<cword>")<CR><CR>
    nmap zf :cs find f <C-R>=expand("<cword>")<CR><CR>
    nmap zi :cs find i ^<C-R>=expand("<cword>")<CR>$<CR>
    nmap zd :cs find d <C-R>=expand("<cword>")<CR><CR>
endif

" 设置 ctrlp
"let g:ctrlp_map = ''   " 去掉ctrl+p快捷键
"let g:ctrlp_reuse_window='netrw'
"let g:ctrlp_switch_buffer = 'Et'
"let g:ctrlp_open_new_file = 'r'
let g:ctrlp_by_filename = 1
let g:ctrlp_max_height = 15
let g:ctrlp_use_caching = 1
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_cache_dir = $VIM.'/cache/ctrlp'
" 手动指定搜索的根目录let g:ctrlp_root_markers = ['']

" clang complete
"let g:clang_auto_select=1  " 自动选中第一个,但不插入代码中
"let g:clang_complete_copen=1  " 自动打开quickfix窗口
"let g:clang_periodic_quickfix=1
"let g:clang_snippets=1
"let g:clang_close_preview=1
"let g:clang_use_library=1
"let g:clang_user_options='-std=c++11 -IIncludePath'

" Syntastic 语法检查
"let g:syntastic_mode_map = {"mode": "passive"}
"set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
"set statusline+=%*
"let g:syntastic_always_populate_loc_list = 1
"let g:syntastic_auto_loc_list = 1
"let g:syntastic_check_on_open = 1  " 这两项控制在何时进行检查 
"let g:syntastic_check_on_wq = 0

 

posted on 2016-01-13 19:53  哥斯达黎加  阅读(173)  评论(0)    收藏  举报

导航