博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
耗时整整一天,整理出的超详细清晰的vim,vimrc配置
阅读量:2392 次
发布时间:2019-05-10

本文共 17036 字,大约阅读时间需要 56 分钟。

Github地址:

多的不多说,耗时整整一天。处女座就是这么不能忍。

超级详细,超级清晰。弄懂vim配置的好范例。你要的都在这里了。希望对你们有所帮助。

" Vundle {
{
{ set nocompatible " be iMproved, required filetype off " required " set the runtime path to include Vundle and initialize set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " alternatively, pass a path where Vundle should install plugin " call vundle#begin('~/some/path/here') " let Vundle manage Vundle, required Plugin 'VundleVim/Vundle.vim' Plugin 'scrooloose/nerdtree' Plugin 'Xuyuanp/nerdtree-git-plugin' Plugin 'jistr/vim-nerdtree-tabs' Plugin 'Valloric/YouCompleteMe' Plugin 'SirVer/ultisnips' Plugin 'honza/vim-snippets' Plugin 'davidhalter/jedi-vim' Plugin 'Raimondi/delimitMate' Plugin 'ctrlpvim/ctrlp.vim' Plugin 'dyng/ctrlsf.vim' Plugin 'majutsushi/tagbar' Plugin 'rking/ag.vim' Plugin 'Lokaltog/vim-easymotion' Plugin 'vim-scripts/matchit.zip' Plugin 'tomtom/tcomment_vim' Plugin 'tpope/vim-surround' Plugin 'terryma/vim-multiple-cursors' Plugin 'scrooloose/syntastic' Plugin 'klen/python-mode' Plugin 'xolox/vim-lua-ftplugin' Plugin 'xolox/vim-misc' Plugin 'fatih/vim-go' Plugin 'posva/vim-vue' Plugin 'tpope/vim-fugitive' Plugin 'gregsexton/gitv' Plugin 'airblade/vim-gitgutter' Plugin 'bling/vim-airline' Plugin 'noahfrederick/vim-hemisu' Plugin 'raymond-w-ko/vim-lua-indent' Plugin 'tomasr/molokai' Plugin 'zaki/zazen' " All of your Plugins must be added before the following line call vundle#end() " required filetype plugin indent on " required " To ignore plugin indent changes, instead use: "filetype plugin on " " Brief help " :PluginList - lists configured plugins " :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate " :PluginSearch foo - searches for foo; append `!` to refresh local cache " :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal " " see :h vundle for more details or wiki for FAQ " Put your non-Plugin stuff after this line" }}}" Vim {
{
{ syntax on set shell=bash let mapleader = ',' set shortmess=atI" " Close welcome page set fillchars=vert:\ set history=1000 " Store lots of :cmdline history set noswapfile " Don't use swapfile set nobackup " Don't create annoying backup files set noerrorbells " No beeps set cursorline " Highlight the current line " set cursorcolumn " Highlight the current column " set mouse-=a " not enable mouse set clipboard+=unnamed " Shared clipboard set backspace=indent,eol,start " Allow backspacing over everything in insert mode set linespace=0 " How to change the space between lines in vim? set updatetime=100 set switchbuf=usetab,usetab " Open new buffers always in new tabs set wildignore+=*/.git/*, " Linux/MacOSX \*/.hg/*,*/.svn/*, \*/cscope*,*/*.csv/, \*/*.log,*tags*,*/bin/* set showcmd " Show me what I'm typing set showmode " Show current mode down the bottom set number " Show line numbers set numberwidth=4 " Number width set showmatch " Do not show matching brackets by flickering set incsearch " Shows the match while typing set hlsearch " Highlight found searches set ignorecase " Search case insensitive... set smartcase " ... but not when search pattern contains upper case characters set shiftwidth=4 " Default indent settings set softtabstop=4 " set expandtab " set autoindent " Automatic indentation set smartindent " Smart indent set encoding=utf-8 " Set default encoding to UTF-8 set fileencodings=utf-8,ucs-bom,gbk,gb2312,gb18030,default set fileformats=unix,dos,mac " Prefer Unix over Windows over OS 9 formats set formatoptions+=tcroqw " set splitright " Split vertical windows right to the current windows set splitbelow " Split horizontal windows below to the current windows set autowrite " Automatically save before :next, :make etc. set autoread " Automatically reread changed files without asking me anything set laststatus=2 " Always show the status line. or 1 " theme setting {
{
{ set guioptions='' set background=dark " Background color set t_Co=256 set guifont=Source\ Code\ Pro\ Light:h13 colorscheme molokai " colorscheme solarized " colorscheme desert " }}} " A buffer becomes hidden when it is abandoned {
{
{ set hidden set wildmode=list:longest set ttyfast " }}} " Code folding {
{
{ set foldenable set foldmethod=indent " manual,indent,expr,syntax,diff,marker set foldlevel=99 let g:FoldMethod = 0 map
zz :call ToggleFold()
fun! ToggleFold() if g:FoldMethod == 0 exe "normal! zM" let g:FoldMethod = 1 else exe "normal! zR" let g:FoldMethod = 0 endif endfun " }}} " simple surround {
{
{ vmap " S" vmap ' S' vmap ` S` vmap [ S[ vmap ( S( vmap { S{ vmap } S} vmap ] S] vmap ) S) " }}} " Smart way to move between windows {
{
{ map
j map
k map
h map
l " }}} " Switch buffer { { { nmap
:bp
nmap
:bn
" }}} " Switch tab { { { noremap
1 1gt noremap
2 2gt noremap
3 3gt noremap
4 4gt noremap
5 5gt noremap
6 6gt noremap
7 7gt noremap
8 8gt noremap
9 9gt noremap
0 :tablast
" }}} " relativenumber { { { set relativenumber augroup CursorLineOnlyInActiveWindow autocmd! autocmd InsertLeave * setlocal relativenumber autocmd InsertEnter * setlocal norelativenumber autocmd BufEnter * setlocal cursorline autocmd BufLeave * setlocal nocursorline autocmd CompleteDone *.go call OnGolangCompleteDone() augroup END function! NumberToggle() if(&relativenumber == 1) set norelativenumber number else set relativenumber endif endfunc nnoremap
:call NumberToggle()
" }}} " Remember last location{ { { autocmd BufReadPost * \ if line("'\"")>0&&line("'\"")<=line("$") | \ exe "normal g'\"" | \ endif "}}} " auto load vimrc " autocmd! BufWritePost .vimrc source % autocmd BufNewFile,BufRead *.define setf define autocmd FileType go :set noexpandtab " Do not use spaces instead of tabs autocmd FileType lua :set shiftwidth=4 autocmd FileType python set tabstop=4 shiftwidth=4 expandtab ai autocmd FileType ruby,javascript,html,css,xml set tabstop=2 shiftwidth=2 softtabstop=2 expandtab ai" }}}" hotkey settings { { { " save file with sudo cmap w!! %!sudo tee > /dev/null % " remove searchs highlight noremap
/ :nohls
" select all map
sa ggvG$ " quickly save the current file nnoremap
w :w
" map ; to : nnoremap ; : " fix for ctags ctrl+] not working nmap
g
"inoremap
:set iminsert=0
" nmap
&diff ? ']c' : '
' " nmap
&diff ? '[c' : '
' if has('conceal') set conceallevel=2 concealcursor=niv endif" }}}" gui { { { if has("gui_macvim") " Make the window slightly transparent set transparency=10 " fullscreen set fullscreen " default
let g:ctrlp_map = '
' nmap
:CtrlPBufTag
imap
:CtrlPBufTag
nmap
:CtrlPBufTagAll
imap
:CtrlPBufTagAll
" delete buffer nmap
:bd
imap
:bd
" comment map
:TComment
vmap
:TComment
gv " ctrlsf nmap
:CtrlSF
=expand("
")
imap
:CtrlSF
=expand("
")
vnoremap
y :CtrlSF"
=escape(@", '\\/.*$^~[]()"')
" " nerdtree map
:NERDTreeTabsToggle
map
e :NERDTreeFind
" Window switch map { { { " map
j " map
k " map
l " map
h " }}} endif" }}}" vim-go { { { let g:go_highlight_functions = 1 let g:go_highlight_methods = 1 let g:go_highlight_fields = 1 let g:go_highlight_types = 1 let g:go_highlight_operators = 1 let g:go_highlight_build_constraints = 1 let g:go_fmt_command = "goimports" let g:go_list_type = "quickfix" nmap
gc :GoErrCheck
nmap
gb :GoBuild
nmap
gd :GoDoc
nmap
gt :GoTest
nmap
gi :GoInstall
nmap
gr :GoRename
function! OnGolangCompleteDone() if !exists('v:completed_item') || empty(v:completed_item) return endif let complete_str = v:completed_item.word if complete_str == '' return endif let line = getline('.') let next_char = line[col('.')-1] if next_char == "(" return end let cur_char =line[col('.')-2] let abbr = v:completed_item.abbr let startIdx = match(abbr,"(") let endIdx = match(abbr,")") if endIdx - startIdx > 1 let argsStr = strpart(abbr, startIdx+1, endIdx - startIdx -1) let argsList = split(argsStr, ",") let snippet = "" if cur_char != "(" let snippet = "(" end let c = 1 for i in argsList if c > 1 let snippet = snippet. ", " endif " strip space let arg = substitute(i, '^\s*\(.\{-}\)\s*$', '\1', '') let snippet = snippet . '${'.c.":".arg.'}' let c += 1 endfor let snippet = snippet . ")$0" call UltiSnips#Anon(snippet) endif endfunction" }}}" NERDTree { { { let g:NERDTreeDirArrows = 0 let g:nerdtree_tabs_open_on_gui_startup = 0" }}}" nerdtree-git-plugin symbols { { { let g:NERDTreeIndicatorMapCustom = { \ "Modified" : "✹", \ "Staged" : "✚", \ "Untracked" : "✭", \ "Renamed" : "➜", \ "Unmerged" : "═", \ "Deleted" : "✖", \ "Dirty" : "✗", \ "Clean" : "✔︎", \ "Unknown" : "?" \ }" }}}" vim-airline { { { let g:airline#extensions#tabline#enabled = 1 let g:airline_theme='dark' let g:airline_powerline_fonts=0 let g:airline#extensions#tabline#exclude_preview = 1 let g:airline#extensions#tabline#show_buffers = 1 let g:airline#extensions#tabline#tab_nr_type = 2 " splits and tab number let g:airline#extensions#bufferline#enabled = 1" }}}" cscope { { { if has("cscope") " set csprg=/usr/local/bin/cscope set csto=0 set cscopequickfix=s-,c-,d-,i-,t-,e- set cst set nocsverb " add any database in current directory if filereadable("cscope.out") cs add cscope.out " else add database pointed to by environment elseif $CSCOPE_DB != "" cs add $CSCOPE_DB endif set csverb nmap
:cs find c
=expand("
")
:copen
nmap
:cs find s
=expand("
")
:copen
nmap
:cs find g
=expand("
")
end" }}}" tagbar { { { map
:TagbarToggle
let g:tagbar_autofocus=1 let g:tagbar_sort=0 let g:tagbar_type_go = { \ 'ctagstype' : 'go', \ 'kinds' : [ \ 'p:package', \ 'i:imports:1', \ 'c:constants', \ 'v:variables', \ 't:types', \ 'n:interfaces', \ 'w:fields', \ 'e:embedded', \ 'm:methods', \ 'r:constructor', \ 'f:functions' \ ], \ 'sro' : '.', \ 'kind2scope' : { \ 't' : 'ctype', \ 'n' : 'ntype' \ }, \ 'scope2kind' : { \ 'ctype' : 't', \ 'ntype' : 'n' \ }, \ 'ctagsbin' : 'gotags', \ 'ctagsargs' : '-sort -silent' \ }" }}}" CtrlP { { { set wildignore+=*/tmp/*,*.so,*.swp,*.zip " MacOSX/Linux set wildignore+=*\\tmp\\*,*.swp,*.zip,*.exe " Windows let g:ctrlp_cmd = 'CtrlPMixed' " search anything (in files, buffers and MRU files at the same time.) let g:ctrlp_by_filename = 1 let g:ctrlp_working_path_mode = 'ra' " search for nearest ancestor like .git, .hg, and the directory of the current file let g:ctrlp_match_window_bottom = 1 " show the match window at the top of the screen let g:ctrlp_max_height = 10 " maxiumum height of match window let g:ctrlp_switch_buffer = 'Et' " jump to a file if it's open already let g:ctrlp_use_caching = 1 " enable caching let g:ctrlp_clear_cache_on_exit=1 " speed up by not removing clearing cache evertime let g:ctrlp_mruf_max = 250 " number of recently opened files let g:ctrlp_open_new_file = 't' let g:ctrlp_open_multiple_files = 't' let g:ctrlp_open_new_file = 'r' let g:ctrlp_custom_ignore = { \ 'dir': '\v[\/](\.git|\.hg|\.svn|\.build|github.com|labix.org|bin|pkg)$', \ 'file': '\v(\.exe|\.so|\.dll|\.a|\.xls|\.csv|\.json|\.log|\.out|gs|gw|gm|tags|gotags|\/U)$', \ 'link': 'SOME_BAD_SYMBOLIC_LINKS', \ } let g:ctrlp_buftag_types = { \ 'go' : '--language-force=go --golang-types=ftv', \ 'as' : '--language-force=actionscript --actionscript-types=fpvc', \ 'actionscript': '--language-force=actionscript --actionscript-types=fpvc', \ 'coffee' : '--language-force=coffee --coffee-types=cmfvf', \ 'markdown' : '--language-force=markdown --markdown-types=hik', \ 'objc' : '--language-force=objc --objc-types=mpci', \ 'rc' : '--language-force=rust --rust-types=fTm' \ } let g:ctrlp_prompt_mappings = { \ 'PrtBS()': ['
', '
'], \ 'PrtDelete()': ['
'], \ 'PrtDeleteWord()': ['
'], \ 'PrtClear()': ['
'], \ 'PrtSelectMove("j")': ['
', '
'], \ 'PrtSelectMove("k")': ['
', '
'], \ 'PrtSelectMove("t")': ['
', '
'], \ 'PrtSelectMove("b")': ['
', '
'], \ 'PrtSelectMove("u")': ['
', '
'], \ 'PrtSelectMove("d")': ['
', '
'], \ 'PrtHistory(-1)': ['
'], \ 'PrtHistory(1)': ['
'], \ 'AcceptSelection("e")': ['
', '<2-LeftMouse>'], \ 'AcceptSelection("h")': ['
', '
', '
'], \ 'AcceptSelection("t")': ['
'], \ 'AcceptSelection("v")': ['
', '
'], \ 'ToggleFocus()': ['
'], \ 'ToggleRegex()': ['
'], \ 'ToggleByFname()': ['
'], \ 'ToggleType(1)': ['
', '
'], \ 'ToggleType(-1)': ['
', '
'], \ 'PrtExpandDir()': ['
'], \ 'PrtInsert("c")': ['
', '
'], \ 'PrtInsert()': ['
'], \ 'PrtCurStart()': ['
'], \ 'PrtCurEnd()': ['
'], \ 'PrtCurLeft()': ['
', '
', '
'], \ 'PrtCurRight()': ['
', '
'], \ 'PrtClearCache()': ['
'], \ 'PrtDeleteEnt()': ['
'], \ 'CreateNewFile()': ['
'], \ 'MarkToOpen()': ['
'], \ 'OpenMulti()': ['
'], \ 'PrtExit()': ['
', '
', '
'], \ }" }}}" syntastic { { { set statusline+=%#warningmsg# set statusline+=%{ SyntasticStatuslineFlag()} set statusline+=%* let g:syntastic_check_on_wq=1 let g:syntastic_auto_jump=1 let g:syntastic_auto_loc_list=1 let g:syntastic_error_symbol = "▶▶" let g:syntastic_warning_symbol = "⚠" " let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck'] " passive let g:syntastic_mode_map = { "mode": "active", \ "active_filetypes": ["ruby", "go", "python"], \ "passive_filetypes": ["shell"] }" }}}" CtrlSF { { { command! CO CtrlSFOpen let g:ctrlsf_winsize = '30%' let g:ctrlsf_auto_close = 0" }}}" YouCompleteMe { { { let g:ycm_error_symbol = '>>' let g:ycm_warning_symbol = '>*' " Specifies Python interpreter to run jedi let g:ycm_python_binary_path = 'python' " Completion when typing inside comments let g:ycm_complete_in_comments = 1 " Query the UltiSnips plugin let g:ycm_use_ultisnips_completer = 1 " Collect identifiers from strings and comments let g:ycm_collect_identifiers_from_comments_and_strings = 1 " " Seed its identifier database " let g:ycm_seed_identifiers_with_syntax=1 " collect identifiers from tags files let g:ycm_collect_identifiers_from_tags_files = 1 " typing 2 chars let g:ycm_min_num_of_chars_for_completion = 2 "youcompleteme 默认tab s-tab 和自动补全冲突 let g:ycm_key_list_select_completion = ['
', '
'] let g:ycm_key_list_previous_completion = ['
', '
'] " Where GoTo* commands result should be opened, same-buffer let g:ycm_goto_buffer_command = 'horizontal-split' " nnoremap
jd :YcmCompleter GoToDefinition
nnoremap
jd :YcmCompleter GoToDefinitionElseDeclaration
nnoremap
gd :YcmCompleter GoToDeclaration
let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py" " blacklist let g:ycm_filetype_blacklist = { \ 'tagbar' : 1, \ 'gitcommit' : 1, \}" }}}" UltiSnips { { { let g:UltiSnipsExpandTrigger = "
" let g:UltiSnipsJumpForwardTrigger = "
" let g:UltiSnipsJumpBackwardTrigger = "
" let g:UltiSnipsSnippetDirectories = ['UltiSnips'] let g:UltiSnipsSnippetsDir = '~/.vim/UltiSnips' " 定义存放代码片段的文件夹 .vim/UltiSnips下,使用自定义和默认的,将会的到全局,有冲突的会提示 " 进入对应filetype的snippets进行编辑 map
us :UltiSnipsEdit
" ctrl+j/k 进行选择 func! g:JInYCM() if pumvisible() return "\
" else return "\
" endif endfunction func! g:KInYCM() if pumvisible() return "\
" else return "\
" endif endfunction inoremap
=g:JInYCM()
au BufEnter,BufRead * exec "inoremap
" . g:UltiSnipsJumpBackwordTrigger . "
=g:KInYCM()
" let g:UltiSnipsJumpBackwordTrigger = "
"" }}}" delimitMate { { { let g:delimitMate_expand_cr = 1 let delimitMate_balance_matchpairs = 1 let g:delimitMate_expand_space = 2 imap
delimitMate#ShouldJump() ? "
delimitMateS-Tab" : "
" inoremap
delimitMate#JumpAny()" }}}" easymotion { { { let g:EasyMotion_smartcase = 1 "let g:EasyMotion_startofline = 0 " keep cursor colum when JK motion map
h
(easymotion-linebackward) map
j
(easymotion-j) map
k
(easymotion-k) map
l
(easymotion-lineforward) map
.
(easymotion-repeat)" }}}" fugitive { { { " :Gdiff :Gstatus :Gvsplit " use zsh alias nnoremap
gaa :Git add .
nnoremap
gc :Gcommit
nnoremap
gp :Gpush
nnoremap
gl :Gpull
nnoremap
gb :Gblame
nnoremap
gst :Gstatus
nnoremap
gd :Gdiff
nnoremap
glg :Glog
" }}}" multiplecursors { { { let g:multi_cursor_use_default_mapping=0 " Default mapping let g:multi_cursor_next_key='
' let g:multi_cursor_prev_key='
' let g:multi_cursor_skip_key='
' let g:multi_cursor_quit_key='
'" }}}hi Pmenu guifg=#F6F3E8 guibg=#444444" hi PmenuSel guifg=#FFFFFF guibg=#0077DDhi PmenuSel guifg=#FFFFFF guibg=#11AADDhi PMenuSbar guibg=#5A647Ehi PMenuThumb guibg=#AAAAAA" hi Visual guibg=#1122FF" hi Visual guibg=#0066FFhi Visual guibg=#2566FA" hi VertSplit guibg=#272822hi VertSplit guibg=#1B1D1Ehi Cursor guibg=#FF0000

转载地址:http://qkrab.baihongyu.com/

你可能感兴趣的文章
图像处理库OpenCV参考网址
查看>>
dllimport与dllexport作用与区别
查看>>
OpenGL坐标系
查看>>
C++用new和不用new创建类对象区别
查看>>
C++ C# JAVA 创建对象
查看>>
齐次坐标的理解
查看>>
QT配置文件
查看>>
QT .pro配置文件2
查看>>
Qt 模态与非模态对话框
查看>>
Qt C++中的关键字explicit .
查看>>
qtcreator中常用快捷键
查看>>
PowerDesigner 简介
查看>>
VS2008快捷键大全
查看>>
Access 操作或事件已被禁用模式阻止
查看>>
C# 控件置于最顶层、最底层
查看>>
几个常见的压缩算法
查看>>
浮点数的存储
查看>>
点到线段的距离
查看>>
HTML_5_Canvas
查看>>
Mysql Fabric实现学习笔记
查看>>