vimrc配置汇总(win版)

-------------------------------------------- 2016-07-23 16:38:18 --------------------------------------------

" ================================= FUNCTIONS =================================
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

" unbuntu自动最大化 需要安装wmctrl
" sudo apt-get install wmctrl function Maximize_Window()   silent !wmctrl -r :ACTIVE: -b add,maximized_vert,maximized_horz endfunction
"标签页栏中去除当前所编辑文件的路径信息,只保留文件名 function ShortTabLabel () let bufnrlist = tabpagebuflist (v:lnum) let label = bufname (bufnrlist[tabpagewinnr (v:lnum) -1]) let filename = fnamemodify (label, ':t') return filename endfunction " 关闭当前打开的文件 function DeleteCurBuf() let l:currentBufNum = bufnr("%") if 0 == buflisted(l:currentBufNum) exec "echo \'This buffer can not delete.\'" return endif if buflisted(bufnr("#")) exec "b#" else exec "bp" endif let l:newBufNum = bufnr("%") if l:currentBufNum == l:newBufNum exec "echo \'This is the last opened file.\'" return endif exec "bw " . l:currentBufNum endfunction function WasCommented(str) let len = strlen(a:str) let i = 0 while i < len if a:str[i] != ' ' && a:str[i] != "\t" break endif let i += 1 endwhile if i < len - 1 && a:str[i] == a:str[i+1] && a:str[i] == "/" return 1 else return 0 endif endfunction function ToggleCommentLine() let nr = line('.') let str_line = getline(nr) if WasCommented(str_line) let newstr = substitute(str_line, '//', '', '') else let newstr = substitute(str_line, '^', '//', '') endif :call setline(nr, newstr) endfunction " 1 tagbar打开了,2 nerdtree打开了,3都打开了,0都没打开 function WhichOpened() let returnValue = 0 if bufwinnr('__Tagbar__') != -1 let returnValue += 1 endif if bufwinnr('NERD_tree_1') != -1 let returnValue += 2 endif return returnValue endfunction function SwitchTagbarNERDTree() let tmp = WhichOpened() exec "NERDTreeClose" if (tmp != 2) && (tmp != 3) exec "TagbarClose" exec "NERDTreeToggle" exec "normal! \<c-w>l" else exec "TagbarOpen" endif endfunction let s:lastTNStatus = 1 function OpenCloseTagbarNERDTree() let currTNStatus = WhichOpened() exec "NERDTreeClose" if currTNStatus != 0 exec "TagbarClose" let s:lastTNStatus = currTNStatus elseif s:lastTNStatus == 1 exec "TagbarOpen" else exec "TagbarClose" exec "NERDTreeToggle" exec "normal! \<c-w>l" endif endfunction function FindFilePath() exec 'TagbarClose' exec 'NERDTreeFind' exec "normal! \<c-w>l" endfunction " This function works only on language is English. function IsQuickfixLoaded() redir => bufoutput exe "silent! buffers!" " This echo clears a bug in printing that shows up when it is not present silent! echo "" redir END return match(bufoutput, "\"\\[Quickfix List\\]\"", 0, 0) != -1 endfunction function ToggleQuickfix() if IsQuickfixLoaded() :ccl :exec "normal! \<c-w>l" else :copen :exec "normal! \<c-w>J" endif endfunction "function SetSatusLine2() " "set statusline=%4n%m\ %1*>\ %*%t%1*\ <%*\ %<%h%w%q%r%F%=%l,\ %c\ :\ %p%%%1*\|%*0x%02B%1*\|%*%{&fileformat}%1*\|%*%{&encoding} " set statusline=%4*NONINS%2*%m%5*\ %t\ %*%<%h%w%q%r%F%=<%n>\ %l,\ %c\ :\ %p%%%1*\|%*0x%02B%1*\|%*%{&fileformat}%1*\|%*%{&encoding} " au InsertEnter * set statusline=%3*INSERT%2*%m%5*\ %t\ %*%<%h%w%q%r%F%=<%n>\ %l,\ %c\ :\ %p%%%1*\|%*0x%02B%1*\|%*%{&fileformat}%1*\|%*%{&encoding} " au InsertLeave * set statusline=%4*NONINS%2*%m%5*\ %t\ %*%<%h%w%q%r%F%=<%n>\ %l,\ %c\ :\ %p%%%1*\|%*0x%02B%1*\|%*%{&fileformat}%1*\|%*%{&encoding} " set laststatus=2 "endfunction function SetSatusLine() let fix_part='%2*%m%5*\ %t\ %*%<%h%w%q%r%F%=<%n>\ %l,\ %c\ :\ %p%%%1*\|%*0x%02B%1*\|%*%{&fileformat}%1*\|%*%{&encoding}' let insert_mode='%3*INSERT' let other_mode='%4*OTHERS' exe 'set statusline=' . other_mode . fix_part exe 'au InsertEnter * set statusline=' . insert_mode . fix_part exe 'au InsertLeave * set statusline=' . other_mode . fix_part set laststatus=2 endfunction " ================================= SETTINGS ================================== set encoding=utf-8 set langmenu=zh_CN.UTF-8 "set menu's language of gvim. language messages en_US.UTF-8 set nocompatible if has("win32") source $VIMRUNTIME/vimrc_example.vim source $VIMRUNTIME/mswin.vim behave mswin set diffexpr=MyDiff() au GuiEnter * simalt ~x " 自动最大化 endif if has("gui_running") "如果在 GUI 环境下运行则设置下面语句 set guifont=Consolas:h11 "set guifont=Dejavu\ Sans\ Mono:h10 set guioptions-=T " 不显示工具栏 set guioptions-=L " 不显示左边滚动条 set guioptions-=r " 不显示右边滚动条 set guioptions-=m set guitablabel=%{ShortTabLabel()} set vb t_vb= " 禁用响铃提醒 au GuiEnter * set t_vb= endif set number set hlsearch set tabstop=4 set expandtab set shiftwidth=4 set autoindent set hidden " 避免当前编辑文档未保存时,在新窗口打开文档 set ignorecase set cursorline "set textwidth=80 " 超过后自动拆行 set colorcolumn=81 set mouse=a set completeopt=menu " 补全设置 call SetSatusLine() set nobackup set noundofile set noswapfile "set nowrap " 不拆行 "set fdm=syntax " 代码折叠方式 set nofoldenable " 启动时关闭折叠 "set syntax enable set cst " tag有多个匹配项时可以提供选择的机会 " 设置自动补全的单词列表,如果没有set complete那么需要按<c-x><c-k>才会出现补全, " 如果设置了set complete那么直接使用<c-n>或<c-p>就可以了。 set dictionary+=~/vim_autocomplete_dic.txt set complete+=k " ------------------------------ 设置快捷键 -------------------------------- nmap Q :call DeleteCurBuf()<cr> nmap <leader>q <c-w>c nmap <leader>b :ls<CR> nmap <leader>n :nohl<CR> nmap <leader>w :update<CR> nmap <leader>e :browse confirm e<CR> nmap <leader>c :cd if has("win32") nmap <leader>s :e c:/users/*******/_vimrc<CR> else nmap <leader>s :e ~/.vimrc<CR> endif nmap ;s <Plug>(easymotion-F) nmap ;f <Plug>(easymotion-f) nmap ;j <Plug>(easymotion-j) nmap ;k <Plug>(easymotion-k) "nmap <c-s-tab> :tabn<cr> nmap <c-s-tab> :bp<cr> nmap <c-l> :tab split<cr> inoremap <c-l> <c-o><del> nmap <c-k> :tabc<cr> nmap <C-Tab> <ESC>:bn<CR> vmap <C-Tab> <ESC>:bn<CR> imap <C-Tab> <ESC>:bn<CR> nmap <s-Tab> <ESC>:b#<CR> vmap <s-Tab> <ESC>:b#<CR> imap <s-Tab> <ESC>:b#<CR> inoremap <c-f> <pagedown> inoremap <c-b> <pageup>nmap <C-x><c-d> :pwd<CR> nmap <c-x><c-s> :cd ..<CR>:pwd<CR> nmap <c-x><c-x> :CtrlPBuffer<cr> nnoremap <c-x><c-z> :nohl<cr> vnoremap <c-x><c-z> <c-c>:nohl<cr> inoremap <c-x><c-z> <c-o>:nohl<cr> nmap <f1> <esc>:call OpenCloseTagbarNERDTree()<cr> vmap <f1> <esc>:call OpenCloseTagbarNERDTree()<cr> imap <f1> <esc>:call OpenCloseTagbarNERDTree()<cr> nmap <f2> <esc>:call SwitchTagbarNERDTree()<cr> vmap <f2> <esc>:call SwitchTagbarNERDTree()<cr> imap <f2> <esc>:call SwitchTagbarNERDTree()<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> nmap <F4> <ESC>:Grep vmap <F4> <ESC>:Grep imap <F4> <ESC>:Grep nmap <f5> :call ToggleCommentLine()<cr> imap <f5> <c-o>:call ToggleCommentLine()<cr> vmap <f5> <esc>:call ToggleCommentLine()<cr> nmap <F6> <ESC>:CtrlPFunky<cr> vmap <F6> <ESC>:CtrlPFunky<cr> imap <F6> <ESC>:CtrlPFunky<cr> nmap <f9> <esc>:call FindFilePath()<cr> vmap <f9> <esc>:call FindFilePath()<cr> imap <f9> <esc>:call FindFilePath()<cr> nmap <F10> <ESC>:call ToggleQuickfix()<CR> vmap <F10> <ESC>:call ToggleQuickfix()<CR> imap <F10> <ESC>:call ToggleQuickfix()<CR> nnoremap <F7> <ESC>:CtrlP<CR> vnoremap <F7> <ESC>:CtrlP<CR> inoremap <F7> <ESC>:CtrlP<CR> nmap <F8> <ESC>:CtrlPBuffer<CR> vmap <F8> <ESC>:CtrlPBuffer<CR> imap <F8> <ESC>:CtrlPBuffer<CR> nnoremap <silent> <F11> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/^/\/\/<CR>/^$x<CR> vnoremap <silent> <F11> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/^/\/\/<CR>/^$x<CR> inoremap <silent> <F11> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/^/\/\/<CR>/^$x<CR> nnoremap <silent> <F12> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/\/\//<CR>/^$x<CR> vnoremap <silent> <F12> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/\/\//<CR>/^$x<CR> inoremap <silent> <F12> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/\/\//<CR>/^$x<CR> " -------------------------------- 设置插件 ---------------------------------- filetype off if has("win32") set rtp+=$VIM/vimfiles/bundle/vundle/ call vundle#rc('$VIM/vimfiles/bundle/') else set rtp+=~/.vim/bundle/vundle/ call vundle#rc('~/.vim/bundle/') endif Bundle 'gmarik/vundle' Bundle 'altercation/vim-colors-solarized' "Bundle 'molokai' "Bundle 'endel/vim-github-colorscheme' "Bundle 'ciaranm/inkpot' "Bundle 'Lokaltog/vim-powerline' "Bundle 'vim-airline/vim-airline' "Bundle 'vim-airline/vim-airline-themes' Bundle 'majutsushi/tagbar' Bundle 'scrooloose/nerdtree' "Bundle 'ervandew/supertab' "Bundle 'yegappan/grep' Bundle 'dkprice/vim-easygrep' Bundle 'easymotion/vim-easymotion' Bundle 'kien/ctrlp.vim' Bundle 'tacahiroy/ctrlp-funky' Bundle 'drmingdrmer/xptemplate' Bundle 'ap/vim-buftabline' "Bundle 'vim-scripts/bufferlist.vim' "Bundle 'mihaifm/bufstop' "Bundle 'itchyny/thumbnail.vim' "Bundle 'tomtom/tselectbuffer_vim' "Bundle 'vim-scripts/PopupBuffer.vim' "Bundle 'vim-scripts/jsbeautify' "Bundle 'othree/xml.vim' "Bundle 'Valloric/YouCompleteMe' "Bundle 'vim-scripts/javacomplete' "Bundle 'artur-shaik/vim-javacomplete2' "Bundle 'vim-scripts/OmniCppComplete' filetype plugin indent on " EasyGrep let g:EasyGrepMode=2 " use TrackExt let g:EasyGrepReplaceWindowMode=2 "autowriteall; create no new windows (when replace) let g:EasyGrepJumpToMatch=0 let g:EasyGrepAllOptionsInExplorer=1 set grepprg=grep\ -n\ -a let g:EasyGrepCommand=1 let g:EasyGrepRecursive=1 let g:EasyGrepSearchCurrentBufferDir=0 let g:EasyGrepFilesToExclude='.svn,.git,.root,bin,target,*.swp,*.gif,*.png,*.jpg,*.svg,*.zip,*.gz,*.class,*.jar,tags,tags.files' " 设置supertab "let g:SuperTabDefaultCompletionType="context" "let g:SuperTabMappingForward = '<s-tab>' "let g:SuperTabMappingBackward = '<tab>' " 设置Tagbar let g:tagbar_left=1 "let g:tagbar_width=30 let g:tagbar_autoclose=0 "let g:tagbar_sort = 0 let g:tagbar_compact = 1 "let g:tagbar_show_linenumbers = 2 " NERDTree "let NERDTreeWinPos='right' let NERDTreeShowLineNumbers=0 let NERDTreeWinSize=40 let NERDTreeMinimalUI=1 " 设置 ctrlp let g:ctrlp_cmd='CtrlPBuffer' let g:ctrlp_working_path_mode = 'rw' let g:ctrlp_by_filename = 1 let g:ctrlp_max_height = 30 let g:ctrlp_max_files = 100000 let g:ctrlp_use_caching = 1 let g:ctrlp_clear_cache_on_exit = 0 if has("win32") let g:ctrlp_cache_dir = $VIM.'/cache/ctrlp' else let g:ctrlp_cache_dir = '~/.ctrlp' endif let g:ctrlp_root_markers = ['.root'] " set my root marker for ctrlp let g:ctrlp_custom_ignore = { \ 'dir': '\v[\/](build|bin|target)$', \ 'file': '\v\.(jar|class|xml|yang|MF|sh|bat|xlsx|files|properties|proto|conf|md|txt|xsd|png|gif|svg|json|gz|less|css|scss)$', \ 'link': 'SOME_BAD_SYMBOLIC_LINKS',} " ctrlp_funky let g:ctrlp_extensions = ['funky'] let g:ctrlp_funky_syntax_highlight = 1 colorscheme solarized

修改了solarized.vim, 增加下面配色

hi User2 ctermbg=red guibg=red " 文件被修改
hi User3 ctermfg=black ctermbg=yellow guifg=black guibg=yellow      " 插入模式
hi User4 ctermfg=black ctermbg=green  guifg=black guibg=darkgreen   " 非插入模式
hi User5 ctermfg=black ctermbg=white  guifg=black guibg=lightyellow " 文件名

 

 


 

OLD

-------------------------------------------- 2106-06-21 11:52:00 --------------------------------------------

" 设置编码
set encoding=utf-8
set langmenu=zh_CN.UTF-8 "set menu's language of gvim. no spaces beside '='
language messages en_US.UTF-8 "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

if has("gui_running")
    "标签页栏中去除当前所编辑文件的路径信息,只保留文件名
function ShortTabLabel ()
    let bufnrlist = tabpagebuflist (v:lnum)
    let label = bufname (bufnrlist[tabpagewinnr (v:lnum) -1])
    let filename = fnamemodify (label, ':t')
    return filename
endfunction
set guitablabel=%{ShortTabLabel()}
endif


"------------------- vim基础设置 --------------------------
set nu
set hlsearch
set tabstop=4
set expandtab
set shiftwidth=4
set autoindent
set hidden                " 避免当前编辑文档未保存时,在新窗口打开文档
set ignorecase
set cursorline 
"set textwidth=80
set colorcolumn=81
set mouse=a
set completeopt=menu     " 补全设置
"set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)
set statusline=%4n%m\ %1*>\ %*%t%1*\ <%*\ %<%h%w%q%r%F%=%l,\ %c\ :\ %p%%%1*\|%*0x%02B%1*\|%*%{&fileformat}%1*\|%*%{&encoding}
"hi myhl guibg=#ff0000
set nobackup
set noundofile
set noswapfile
set laststatus=2
"set nowrap  " 不拆行
set fdm=syntax  " 代码折叠方式
set nofoldenable " 启动时关闭折叠
"set syntax enable
if has("gui_running")   "如果在 GUI 环境下运行则设置下面语句 
    set guifont=Consolas:h12
    "set guifont=Dejavu\ Sans\ Mono:h10
    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 
endif

if has("win32")
    au GuiEnter * simalt ~x
endif


" --------------------------设置 常用快捷键--------------------------------
function DeleteCurBuf()
    let l:currentBufNum = bufnr("%")
    if 0 == buflisted(l:currentBufNum)
        exec "echo \'This buffer can not delete.\'"
        return
    endif
    exec "bn"
    let l:newBufNum = bufnr("%")
    if l:currentBufNum == l:newBufNum
        exec "echo \'This is the last opened file.\'"
        return
    endif
    exec "bw " . l:currentBufNum
endfunction
nmap Q :call DeleteCurBuf()<cr>
nmap <leader>q :q<CR>
nmap <leader>b :ls<CR>
nmap <leader>n :nohl<CR>
nmap <leader>w :update<CR>
nmap <leader>W :wa<CR>
nmap <leader>e :browse confirm e<CR>
"nmap <leader>s :e $VIM/_vimrc<CR>
nmap <leader>s :e c:/users/*******/_vimrc<CR>
nmap <leader>c :cd 

"let g:EasyMotion_leader_key = ';'
nmap ;s <Plug>(easymotion-F)
nmap ;f <Plug>(easymotion-f)
nmap ;j <Plug>(easymotion-j)
nmap ;k <Plug>(easymotion-k)

nmap <C-d><c-d> :pwd<CR>
nmap <c-d><c-s> :cd ..<CR>:pwd<CR>
nmap <c-s-tab> :tabn<cr>
nmap <c-l> :tab split<cr>
nmap <c-k> :tabc<cr>

nmap <S-Tab> <ESC>:bn<CR>
vmap <S-Tab> <ESC>:bn<CR>
imap <S-Tab> <ESC>:bn<CR>
nmap <C-Tab> <ESC>:b#<CR>
vmap <C-Tab> <ESC>:b#<CR>
imap <C-Tab> <ESC>:b#<CR>
map <c-w>, <esc>:vertical resize +3<cr>
map <c-w>. <esc>:vertical resize -3<cr>

function WasCommented(str)
    let len = strlen(a:str)
    let i = 0
    while i < len
        if a:str[i] != ' ' || a:str[i] != "\t"
            break
        endif
        let i += 1
    endwhile
    if i < len - 1 && a:str[i] == a:str[i+1] && a:str[i] == "/"
        return 1
    else
        return 0
    endif
endfunction
function ToggleCommentLine()
    let nr = line('.')
    let str_line = getline(nr)
    if WasCommented(str_line)
        let newstr = substitute(str_line, '//', '', '')
    else
        let newstr = substitute(str_line, '^', '//', '')
    endif
    :call setline(nr, newstr)
endfunction

nmap <f5> <esc>:call ToggleCommentLine()<cr>
imap <f5> <esc>:call ToggleCommentLine()<cr>
vmap <f5> <esc>:call ToggleCommentLine()<cr>

" 1 tagbar打开了,2 nerdtree打开了,3都打开了,0都没打开
function WhichOpened()
    let returnValue = 0
    if bufwinnr('__Tagbar__') != -1
        let returnValue += 1
    endif
    if bufwinnr('NERD_tree_1') != -1
        let returnValue += 2
    endif
    return returnValue
endfunction
function SwitchTagbarNERDTree()
    let tmp = WhichOpened()
    exec "NERDTreeClose"
    if (tmp != 1) && (tmp != 3)
        exec "TagbarOpen"
    else
        exec "TagbarClose"
        exec "NERDTreeToggle"
        exec "normal! \<c-w>l"
    endif
endfunction

let s:lastTNStatus = 1
function OpenCloseTagbarNERDTree()
    let currTNStatus = WhichOpened()
    exec "NERDTreeClose"
    if currTNStatus != 0
        exec "TagbarClose"
        let s:lastTNStatus = currTNStatus
    elseif s:lastTNStatus == 1
        exec "TagbarOpen"
    else
        exec "TagbarClose"
        exec "NERDTreeToggle"
        exec "normal! \<c-w>l"
    endif
endfunction

nmap <f1> <esc>:call OpenCloseTagbarNERDTree()<cr>
vmap <f1> <esc>:call OpenCloseTagbarNERDTree()<cr>
imap <f1> <esc>:call OpenCloseTagbarNERDTree()<cr>
nmap <f2> <esc>:call SwitchTagbarNERDTree()<cr>
vmap <f2> <esc>:call SwitchTagbarNERDTree()<cr>
imap <f2> <esc>:call SwitchTagbarNERDTree()<cr>
"nmap <F1> <esc>:NERDTreeClose<cr>:TagbarOpen<cr>
"vmap <F1> <esc>:NERDTreeClose<cr>:TagbarOpen<cr>
"imap <F1> <esc>:NERDTreeClose<cr>:TagbarOpen<cr>
"nmap <F2> <esc>:TagbarClose<cr>:NERDTreeClose<cr>:NERDTreeToggle<cr>
"vmap <F2> <esc>:TagbarClose<cr>:NERDTreeClose<cr>:NERDTreeToggle<cr>
"imap <F2> <esc>:TagbarClose<cr>:NERDTreeClose<cr>:NERDTreeToggle<cr>
nmap <c-f9> :NERDTreeFind<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>
nmap <F4> <ESC>:Grep 
vmap <F4> <ESC>:Grep 
imap <F4> <ESC>:Grep 
"nmap <F5> <ESC>:NERDTreeClose<cr>:TagbarClose<cr>
"vmap <F5> <ESC>:NERDTreeClose<cr>:TagbarClose<cr>
"imap <F5> <ESC>:NERDTreeClose<cr>:TagbarClose<cr>
nmap <F6> <ESC>:CtrlPFunky<cr>
vmap <F6> <ESC>:CtrlPFunky<cr>
imap <F6> <ESC>:CtrlPFunky<cr>
nnoremap <silent> <F11> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/^/\/\/<CR>/^$x<CR>
vnoremap <silent> <F11> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/^/\/\/<CR>/^$x<CR>
inoremap <silent> <F11> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/^/\/\/<CR>/^$x<CR>
nnoremap <silent> <F12> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/\/\//<CR>/^$x<CR>
vnoremap <silent> <F12> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/\/\//<CR>/^$x<CR>
inoremap <silent> <F12> <ESC>:<C-R>=line("'<")<CR>,<C-R>=line("'>")<CR>s/\/\//<CR>/^$x<CR>

function FindFilePath()
    exec 'TagbarClose'
    exec 'NERDTreeFind'
    exec "normal! \<c-w>l"
endfunction
nmap <f9> <esc>call FindFilePath()<cr>
vmap <f9> <esc>call FindFilePath()<cr>
imap <f9> <esc>call FindFilePath()<cr>

function IsQuickfixLoaded()
    redir => bufoutput
    exe "silent! buffers!"
    " This echo clears a bug in printing that shows up when it is not present
    silent! echo ""
    redir END
    return match(bufoutput, "\"\\[Quickfix List\\]\"", 0, 0) != -1
endfunction
function ToggleQuickfix()
    if IsQuickfixLoaded()
        :ccl
        :exec "normal! \<c-w>l"
    else
        :copen
        :exec "normal! \<c-w>J"
    endif
endfunction
nmap <F10> <ESC>:call ToggleQuickfix()<CR>
vmap <F10> <ESC>:call ToggleQuickfix()<CR>
imap <F10> <ESC>:call ToggleQuickfix()<CR>
nnoremap <F7> <ESC>:CtrlP<CR>
vnoremap <F7> <ESC>:CtrlP<CR>
inoremap <F7> <ESC>:CtrlP<CR>
nmap <F8> <ESC>:CtrlPBuffer<CR>
vmap <F8> <ESC>:CtrlPBuffer<CR>
imap <F8> <ESC>:CtrlPBuffer<CR>

" -----------------------------------设置各插件-------------------------------------
" Bundle
filetype off
" 设置vundle路径
set rtp+=$VIM/vimfiles/bundle/vundle/
call vundle#rc('$VIM/vimfiles/bundle/')  
Bundle 'gmarik/vundle'
 
"Bundle 'altercation/vim-colors-solarized'
Bundle 'molokai'
"Bundle 'ciaranm/inkpot'
"Bundle 'Lokaltog/vim-powerline'
"Bundle 'vim-airline/vim-airline'
"Bundle 'vim-airline/vim-airline-themes'
Bundle 'majutsushi/tagbar'
Bundle 'scrooloose/nerdtree'
Bundle 'ervandew/supertab'
"Bundle 'yegappan/grep'
Bundle 'dkprice/vim-easygrep'
Bundle 'easymotion/vim-easymotion'
Bundle 'kien/ctrlp.vim'
Bundle 'tacahiroy/ctrlp-funky'
Bundle 'drmingdrmer/xptemplate'
Bundle 'vim-scripts/jsbeautify'
"Bundle 'othree/xml.vim'
"Bundle 'Valloric/YouCompleteMe'
"Bundle 'vim-scripts/javacomplete'
"Bundle 'artur-shaik/vim-javacomplete2'
"Bundle 'vim-scripts/OmniCppComplete'
filetype plugin indent on

" 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" --include="*.java"'
"let Grep_Default_Filelist = '.'

" EasyGrep
let g:EasyGrepMode=2 " use TrackExt
let g:EasyGrepReplaceWindowMode=2 "autowriteall; create no new windows (when replace)
let g:EasyGrepJumpToMatch=0
let g:EasyGrepAllOptionsInExplorer=1
"let g:EasyGrepRoot="search:.git,.svn,.root"
set grepprg=grep\ -n\ -a
let g:EasyGrepCommand=1
let g:EasyGrepRecursive=1
let g:EasyGrepSearchCurrentBufferDir=0
let g:EasyGrepFilesToExclude='.svn,.git,.root,bin,target,*.swp'

" 设置supertab
let g:SuperTabDefaultCompletionType="context"
let g:SuperTabMappingForward = '<s-tab>'
let g:SuperTabMappingBackward = '<tab>'


" 设置Tagbar
let g:tagbar_left=1
"let g:tagbar_width=30
let g:tagbar_autoclose=0
"let g:tagbar_sort = 0
let g:tagbar_compact = 1
"let g:tagbar_show_linenumbers = 2

" NERDTree
"let NERDTreeWinPos='right'
let NERDTreeShowLineNumbers=0
let NERDTreeWinSize=40

" 设置 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_cmd='CtrlPBuffer'
let g:ctrlp_working_path_mode = 'rw'
let g:ctrlp_by_filename = 1
let g:ctrlp_max_height = 30
let g:ctrlp_max_files = 50000
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 = ['']
let g:ctrlp_root_markers = ['.root']  " set my root marker for ctrlp
"let g:ctrlp_custom_ignore = '\v[\/](build|bin|src\\win32)$'
let g:ctrlp_custom_ignore = {
    \ 'dir': '\v[\/](build|bin|target)$',
    \ 'file': '\v\.(jar|class)$',
    \ 'link': 'SOME_BAD_SYMBOLIC_LINKS',}

let g:ctrlp_extensions = ['funky']
let g:ctrlp_funky_syntax_highlight = 1

"set bg=light
"colorscheme solarized
"colorscheme desert
"let g:molokai_original=1
colorscheme molokai 
"colorscheme inkpot

"let g:Powerline_colorscheme='solarized256'
"let g:Powerline_colorscheme='default'
"let g:Powerline_stl_path_style = 'full'
"let g:airline#extensions#disable_rtp_load = 1
"let g:airline_section_error = ""
"let g:airline_section_warning = ""
"let g:airline_detect_modified=0

"
" vim-javacomplete2
"autocmd FileType java setlocal omnifunc=javacomplete#Complete

 

the end.

posted on 2016-06-21 11:55  哥斯达黎加  阅读(972)  评论(0编辑  收藏  举报

导航