我的vim配置,我使用了很多插件:a.vim ,auto-pairs,ctags,gundo,indentLine,minibufexpl.vim,neocomplete.vim,nerdcommenter,NERD_tree,rainbow.vim,supertab,syntastic,taglist,vim-multiple-cursors,winmanager等插件
可以下载,对应本文档的插件
set nocompatible " 去除VI一致性,必须要添加
" filetype off " 必须要添加
set nu " 设置vim显示行号
set ts=2
set mousemodel=popup
set ru " 打开状态栏标尺 在右下角显示行号
set hls "搜索高亮
set ignorecase "搜索忽略大小写
set is
set showcmd " 输入的命令显示出来,看的清楚些
set autowrite " 自动保存
set incsearch " 设置增量搜索模式,在搜索时,输入的词句的逐字符高亮
set gdefault
set syntax=on " 语法高亮
set cursorline " 行高亮
set cursorcolumn "列高亮
set showmatch "在输入括号时光标会短暂地跳到与之相匹配的括号处,不影响输入
set foldenable " 允许折叠
set foldmethod=manual " 手动折叠
set laststatus=2 " 启动显示状态行(1),总是显示状态行(2
set whichwrap=b,s,<,>,[,] " 跨行移动
set smartindent " 换行时使用智能缩进
set autoindent " 自动缩进
" indentline if等语句的代码块连接线
let g:indentLine_color_term = 239
let g:indentLine_char = '¦' " 设置连接线的形状 , ¦, ┆, │, ⎸, or ▏
set fenc=gbk " 设置支持中文设置
" set guifont=Courier_New:h11:cANSI " 设置字体
" set guifontwide=YouYuan:h11:cGB2312 " 设置中文字体
"set guifont=Consolas\ 12 "雅黑和Consolas
"set guifontwide=Microsoft/YaHei:h12
"set guifont=新
set guifont=Monaco:h13
if has('gui_running')
set guioptions-=T " no toolbar
colorscheme elflord
set lines=60 columns=108 linespace=0
if has('gui_win32')
set guifont=DejaVu_Sans_Mono:h10:cANSI
else
set guifont=DejaVu\ Sans\ Mono\ 10
endif
endif
"让vim记忆上次编辑的位置
autocmd BufReadPost *
\ if line("'\"")>0&&line("'\"")<=line("$") |
\ exe "normal g'\"" |
\ endif
"让vim记忆上次编辑的位置
"supertab 补全的方式
let g:SuperTabRetainCompletionType=2 " 0 - 不记录上次的补全方式 1 - 记住上次的补全方式,直到用其他的补全命令改变它 2 - 记住上次的补全方式,直到按ESC退出插入模式为止
" Gundo 撤销编辑的操作记录库F5打开关闭
nnoremap :GundoToggle
let g:gundo_width = 60 " 设置宽度
let g:gundo_preview_height = 20
" let g:gundo_right = 1 " 在右边显示
" NERD_commenter 注释所用
let mapleader = "," " 将符变为,
" TagsList
let Tlist_Use_Right_Window=1 "让窗口显示在右边,0的话就是显示在左边
let Tlist_Show_One_File=1 "0让taglist可以同时展示多个文件的函数列表,1只显示当前的文件列表
let Tlist_File_Fold_Auto_Close=1 "非当前文件,函数列表折叠隐藏
let Tlist_Exit_OnlyWindow=1 "当taglist是最后一个分割窗口时,自动推出vim
map tl :TlistToogle " 使用t+l键可以快捷打开和关闭Tlist
let g:NERDTree_title="[NERDTree]"
let g:winManagerWindowLayout="NERDTree|TagList"
let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1 "这个作用是使用快捷键 CTRL + TAB 和 CTRL +SHIFT + TAB才能看的出来
let g:miniBufExplModSelTarget = 1
let g:miniBufExplMoreThanOne=0
"解决FileExplorer窗口变小问题
" let g:miniBufExplForceSyntaxEnable = 1
" let g:miniBufExplorerMoreThanOne=2
let g:NERDTree_title="[NERDTree]"
let g:winManagerWindowLayout="NERDTree|TagList"
function! NERDTree_Start()
exec 'NERDTree'
endfunction
function! NERDTree_IsValid()
return 1
endfunction
nmap wm :WMToggle
"syntastic
"设置error和warning的标志
let g:syntastic_enable_signs = 1
let g:syntastic_error_symbol='✗'
let g:syntastic_warning_symbol='►'
"总是打开Location List(相当于QuickFix)窗口,如果你发现syntastic因为与其他插件冲突而经常崩溃,将下面选项置0
let g:syntastic_always_populate_loc_list = 1
"自动打开Locaton List,默认值为2,表示发现错误时不自动打开,当修正以后没有再发现错误时自动关闭,置1表示自动打开自动关闭,0表示关闭自动打开和自动关闭,3表示自动打开,但不自动关闭
let g:syntastic_auto_loc_list = 1
"修改Locaton List窗口高度
let g:syntastic_loc_list_height = 5
"打开文件时自动进行检查
let g:syntastic_check_on_open = 1
"自动跳转到发现的第一个错误或警告处
let g:syntastic_auto_jump = 1
"进行实时检查,如果觉得卡顿,将下面的选项置为1
let g:syntastic_check_on_wq = 0
"高亮错误
let g:syntastic_enable_highlighting=1
"让syntastic支持C++11
"let g:syntastic_cpp_compiler = 'clang++'
"let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++'
let g:syntastic_cpp_checkers = ['gcc']
let g:syntastic_cpp_compiler = 'gcc'
let g:syntastic_cpp_compiler_options = '-std=c++11'
"设置pyflakes为默认的python语法检查工具
let g:syntastic_python_checkers = ['pyflakes']
"修复syntastic使用:lnext和:lprev出现的跳转问题,同时修改键盘映射使用sn和sp进行跳转
function! LocationPrevious()
try
lprev
catch /^Vim\%((\a\+)\)\=:E553/
llast
endtry
endfunction
function! LocationNext()
try
lnext
catch /^Vim\%((\a\+)\)\=:E553/
lfirst
endtry
endfunction
nnoremap LocationPrevious :exe 'call LocationPrevious()'
nnoremap LocationNext :exe 'call LocationNext()'
nmap sp LocationPrevious
nmap sn LocationNext
"关闭syntastic语法检查, 鼠标复制代码时用到, 防止把错误标志给复制了
nnoremap ec :SyntasticToggleMode
function! ToggleErrors()
let old_last_winnr = winnr('$')
lclose
if old_last_winnr == winnr('$')
" Nothing was closed, open syntastic error location panel
Errors
endif
endfunction
" neocomplete 补全配置
"Note: This option must be set in .vimrc(_vimrc). NOT IN .gvimrc(_gvimrc)!
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplete#sources#syntax#min_keyword_length = 3
" Define dictionary.
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
" Define keyword.
if !exists('g:neocomplete#keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'
" Plugin key-mappings.
inoremap neocomplete#undo_completion()
inoremap neocomplete#complete_common_string()
" Recommended key-mappings.
" : close popup and save indent.
inoremap =my_cr_function()
function! s:my_cr_function()
return (pumvisible() ? "\" : "" ) . "\"
" For no inserting key.
"return pumvisible() ? "\" : "\"
endfunction
" : completion.
inoremap pumvisible() ? "\" : "\"
" , : close popup and delete backword char.
inoremap neocomplete#smart_close_popup()."\"
inoremap neocomplete#smart_close_popup()."\"
" Close popup by .
"inoremap pumvisible() ? "\" : "\"
" AutoComplPop like behavior.
"let g:neocomplete#enable_auto_select = 1
" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplete#enable_auto_select = 1
"let g:neocomplete#disable_auto_complete = 1
"inoremap pumvisible() ? "\" : "\\"
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
"let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
"let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
"let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'
" For perlomni.vim setting.
" https://github.com/c9s/perlomni.vim
let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
"rainbow 括号染色变化
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'tex': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
\
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\ },
\ 'vim': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
\ },
\ 'html': {
\ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ > ])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#\z1># fold'],
\ },
\ 'css': 0,
\ }
\ }
" multi_cursor 编辑方式,可以块编辑 可以用来快速注释,或者编辑
"ctrl+n 选中一个
"ctrl+p 放弃一个, 回到上一个
"ctrl+x 跳过当前选中, 选中下一个
"esc 退出
let g:multi_cursor_start_word_key = ''
let g:multi_cursor_select_all_word_key = ''
let g:multi_cursor_start_key = 'g'
let g:multi_cursor_select_all_key = 'g'
let g:multi_cursor_next_key = ''
let g:multi_cursor_prev_key = ''
let g:multi_cursor_skip_key = ''
let g:multi_cursor_quit_key = ''
" Vim-multiple-cursors与neocomplete的冲突 不但每个光标都有个提示窗口,还很卡
" Called once right before you start selecting multiple cursors
"function! Multiple_cursors_before()
" if exists(':NeoCompleteLock')==2
" exe 'NeoCompleteLock'
" endif
" endfunction
"
" " Called once only when the multiple selection is canceled (default )
" function! Multiple_cursors_after()
" if exists(':NeoCompleteUnlock')==2
" exe 'NeoCompleteUnlock'
" endif
" endfunction
"
"
" ----------------------------- Vundle Start -----------------------------
"set nocompatible
"filetype off
"set rtp+=~/.vim/bundle/Vundle.vim
"call vundle#begin()
"Plugin 'VundleVim/Vundle.vim'
"call vundle#end()
"filetype plugin indent on
" ----------------------------- Vundle End -----------------------------