VIM配置
pathogen插件管理。
这个插件要手动git clone。不使用vundle的原因是github太卡,git clone不可控~
execute pathogen#infect()
syntax on
filetype plugin indent on
Tomorrow 比较好看的颜色主题。
set t_Co=256
colorscheme Tomorrow-Night
set cursorline
set cursorcolumn
**基础配置**
set termencoding=utf-8
set encoding=utf-8
set fileencodings=utf-8,gb18030,utf-16,big5
filetype on
filetype plugin on
filetype indent on
syntax on
syntax enable
set autoread
set nu
set nocompatible
set history=400
set mouse=a
set showcmd
set hlsearch
set incsearch
set title
set noswapfile
set ai
set si
set autoindent
set cindent
set expandtab
set smarttab
set ts=4
set tabstop=4
set shiftwidth=4
set softtabstop=4
set backspace=indent,eol,start
set noerrorbells
set vb t_vb=
let mapleader=","
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
nmap <leader>r <ESC>:s/<C-r><C-w>/<C-r><C-w>/g
nnoremap <leader>g <ESC>:vimgrep /\<<C-r><C-w>\>/g **/*.*
nnoremap <leader><leader>g <ESC>:vimgrep /<C-r><C-w>/g **/*.*
nnoremap <F3> <ESC>:cp<CR>
nnoremap <F4> <ESC>:cn<CR>
nnoremap <leader><F3> <ESC>:cold<CR>
nnoremap <leader><F4> <ESC>:cnew<CR>
nnoremap + :bn<CR>
nnoremap _ :bp<CR>
nnoremap <leader>= <ESC>:vertical res +5<CR>
nnoremap <leader>- <ESC>:vertical res -5<CR>
tnoremap <C-h> <C-w>h
tnoremap <C-j> <C-w>j
tnoremap <C-k> <C-w>k
tnoremap <C-l> <C-w>l
tnoremap <F5> step<CR>
tnoremap <F6> next<CR>
tnoremap <F7> finish<CR>
tnoremap <F8> continue<CR>
tnoremap <F9> break
nnoremap <F5> <ESC>:Step<CR>
nnoremap <F6> <ESC>:Over<CR>
nnoremap <F7> <ESC>:Finish<CR>
nnoremap <F8> <ESC>:Continue<CR>
nnoremap <F9> <ESC>:Break<CR>
nnoremap <F11> <ESC>:Clear<CR>
nnoremap <F10> <ESC>:Evaluate<CR>
vnoremap <F10> :Evaluate<CR>
nnoremap E $
vnoremap E $
nnoremap B ^
vnoremap B ^
nnoremap <leader>w <C-^>
inoremap <A-Space> <ESC>
cnoremap <A-Space> <ESC>
inoremap <C-e> <End>
inoremap <C-a> <Home>
inoremap <C-O> <ESC>o
inoremap <C-b> <Left>
inoremap <C-L> <Right>
inoremap <C-J> <Down>
inoremap <C-K> <Up>
cnoremap <C-e> <End>
cnoremap <C-a> <Home>
cnoremap <C-b> <Left>
cnoremap <C-L> <Right>
cnoremap <C-J> <Down>
cnoremap <C-K> <Up>
set cscopequickfix=s-,c-,d-,i-,t-,e-
nmap <leader>ds <ESC>:cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <leader>dg <ESC>:cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <leader>dc <ESC>:cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <leader>dt <ESC>:cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <leader>de <ESC>:cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <leader>df <ESC>:cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <leader>di <ESC>:cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap <leader>dd <ESC>:cs find d <C-R>=expand("<cword>")<CR><CR>
nmap <leader><leader>ds <ESC>:cs find s <C-R>=expand("<cword>")<CR>
nmap <leader><leader>dg <ESC>:cs find g <C-R>=expand("<cword>")<CR>
nmap <leader><leader>dc <ESC>:cs find c <C-R>=expand("<cword>")<CR>
nmap <leader><leader>dt <ESC>:cs find t <C-R>=expand("<cword>")<CR>
nmap <leader><leader>de <ESC>:cs find e <C-R>=expand("<cword>")<CR>
nmap <leader><leader>df <ESC>:cs find f <C-R>=expand("<cfile>")<CR>
nmap <leader><leader>di <ESC>:cs find i ^<C-R>=expand("<cfile>")<CR>
nmap <leader><leader>dd <ESC>:cs find d <C-R>=expand("<cword>")<CR>
" ignore <leader>s
nnoremap <Leader>s <Nop>
nnoremap <C-P> <Nop>
imap <C-S> <ESC>:w<CR>a
nmap <C-S> <ESC>:w<CR>
tagbar
显示当前bug的tag,比taglist要稍微好些
let g:tagbar_ctags_bin = 'ctags' "tagbar以来ctags插件
let g:tagbar_left = 1 "让tagbar在页面左侧显示,默认右边
let g:tagbar_width = 30 "设置tagbar的宽度为30列,默认40
let g:tagbar_autofocus = 1 "这是tagbar一打开,光标即在tagbar页面内,默认在vim打开的文件内
let g:tagbar_sort = 0 "设置标签不排序,默认排序
airline
状态栏优化,好看很多。还可以把buffers显示到最上面。
set laststatus=2
let g:airline#extensions#tabline#enabled=1
let g:airline#extensions#tabline#buffer_nr_show=1
let g:airline#extensions#whitespace#enable=0
let g:airline#extensions#whitespace#symbol='!'
"let g:airline_left_sep='>'
"let g:airline_right_sep='<'
let g:airline_left_sep='►'
let g:airline_right_sep='◄'
目录文件管理 nerdtree
""修改树的显示图标
let g:NERDTreeDirArrowExpandable = '+'
let g:NERDTreeDirArrowCollapsible = '-'
""窗口位置
let g:NERDTreeWinPos='right'
""窗口尺寸
let g:NERDTreeSize=30
""窗口是否显示行号
let g:NERDTreeShowLineNumbers=1
""不显示隐藏文件
let g:NERDTreeHidden=0
""打开vim时如果没有文件自动打开NERDTree
"autocmd vimenter * if !argc()|NERDTree|endif
""当NERDTree为剩下的唯一窗口时自动关闭
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
""打开vim时自动打开NERDTree
"autocmd vimenter * NERDTree
auto-pairs
自动补全成对的符号。例如:()、""等
模糊查找工具 LeaderF/CtrlP/unite
快速查找目录文件,tag等,支持模糊查找,正则匹配等。
LeaderF使用Python写的,异步调用,效率更快,文件很多也不会卡死~
let g:Lf_WindowHeight=0.30
nnoremap <C-p>p <ESC>:Leaderf file<CR>
nnoremap <C-p>b <ESC>:Leaderf buffer<CR>
nnoremap <C-p>f <ESC>:Leaderf function<CR>
nnoremap <C-p>T <ESC>:Leaderf bufTag<CR>
nnoremap <C-p>t <ESC>:Leaderf tag<CR>
nnoremap <C-p>l <ESC>:Leaderf line<CR>
nnoremap <C-p>a <ESC>:Leaderf self<CR>
nnoremap <C-p><C-p>p <ESC>:Leaderf file --stayOpen<CR>
nnoremap <C-p><C-p>b <ESC>:Leaderf buffer --stayOpen<CR>
nnoremap <C-p><C-p>f <ESC>:Leaderf function --stayOpen<CR>
nnoremap <C-p><C-p>T <ESC>:Leaderf bufTag --stayOpen<CR>
nnoremap <C-p><C-p>t <ESC>:Leaderf tag --stayOpen<CR>
nnoremap <C-p><C-p>l <ESC>:Leaderf line --stayOpen<CR>
nnoremap <C-p><C-p>a <ESC>:Leaderf self --stayOpen<CR>
nnoremap <C-p>g <ESC>:<C-U><C-R>=printf("Leaderf! rg -e %s", expand("<cword>"))<CR>
nnoremap <C-p>G <ESC>:Leaderf! rg --recall<CR>
nnoremap <C-p><C-p>g <ESC>:<C-U><C-R>=printf("Leaderf! rg --stayOpen -e %s", expand("<cword>"))<CR>
nnoremap <C-p><C-p>G <ESC>:Leaderf! rg --recall --stayOpen<CR>
YouCompleteMe
自动补全工具,使用了第三方库,是另外的git路径,要确保第三方库都成功下载后,再编译。
github太卡,嵌套下载第三方库很容易下载不成功,可以单独下载,成功率高些~
要想看嵌套了哪些库,可以在git配置里查到。
" ycm
" set completeopt-=preview
set completeopt=menu,menuone
let g:ycm_add_preview_to_completeopt = 0
let g:ycm_show_diagnostics_ui = 0 " 禁用语法检查
nmap <leader>a <ESC>:YcmCompleter GoToDefinitionElseDeclaration<CR>
let g:ycm_server_python_interpreter='python3'
" let g:ycm_server_python_interpreter='/polestar_build/home/dev/app/python36/bin/python3.6'
"let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py'
"set runtimepath+=~/.vim/bundle/YouCompleteMe
" autocmd InsertLeave * if pumvisible() == 0|pclose|endif "离开插入模式后自动关闭预览窗口
let g:ycm_collect_identifiers_from_tags_files = 1 " 开启 YCM基于标签引擎
"let g:syntastic_ignore_files=[".*\.py$"]
let g:ycm_seed_identifiers_with_syntax = 1 " 语法关键字补全
let g:ycm_confirm_extra_conf = 0 " 关闭加载.ycm_extra_conf.py提示
"let g:ycm_key_list_select_completion = ['<c-n>', '<Down>'] " 映射按键,没有这个会拦截掉tab, 导致其他插件的tab不能用.
"let g:ycm_key_list_previous_completion = ['<c-p>', '<Up>']
let g:ycm_complete_in_comments = 1 " 在注释输入中也能补全
let g:ycm_complete_in_strings = 1 " 在字符串输入中也能补全
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释和字符串中的文字也会被收入补全
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
"inoremap <expr> <CR> pumvisible() ? \"\<C-y>" : \"\<CR>" " 回车即选中当前项
"nnoremap <c-j> :YcmCompleter GoToDefinitionElseDeclaration<CR> " 跳转到定义处
let g:ycm_min_num_of_chars_for_completion=2 " 从第2个键入字符就开始罗列匹配项
" let g:ycm_semantic_triggers = {'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'], \ 'cs,lua,javascript': ['re!\w{2}'], }
let g:ycm_filetype_whitelist = {"c":1, "cpp":1, "objc":1, "python":1, "java":1, "sh":1, "zsh":1, "html":1, "javascript":1, "css":1}
let g:ycm_semantic_triggers = {"c,cpp,python,java,sh,html,javascript,css":["re!\w{2}"]}
vim-easymotion
" plugin easymotion
map <Leader>l <Plug>(easymotion-lineforward)
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
map <Leader>h <Plug>(easymotion-linebackward)
vim-surround
nerdcommenter
let g:NERDSpaceDelims=1
let g:NERDCompactSexyComs = 1
let g:NERDDefaultAlign = 'left'
let g:NERDCommentEmptyLines = 1
let g:NERDCreateDefaultMappings=0
map <leader>/ <plug>NERDCommenterAltDelims
map <leader># <plug>NERDCommenterToggle
indentLine
nnoremap <leader><SPACE> <ESC>:IndentLinesToggle<CR>
set list
set listchars=tab:>-,trail:.
ultisnips
" plugin ultisnips
" plugin vim-snippets {{{1
let g:UltiSnipsExpandTrigger="<C-j>"
let g:UltiSnipsJumpForwardTrigger="<c-f>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"