Created
April 15, 2019 07:42
-
-
Save pansila/5314019c3a66607567fd39311a50bbfb to your computer and use it in GitHub Desktop.
my VIM config file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scriptencoding utf-8 | |
set tabstop=4 " 设置制表符(tab键)的宽度 | |
set softtabstop=4 " 设置软制表符的宽度 | |
set shiftwidth=4 " (自动) 缩进使用的8个空格 | |
set cindent " 使用 C/C++ 语言的自动缩进方式 | |
set cinoptions={0,1s,t0,p2s,(03s,=.5s,>1s,=1s,:1s "设置C/C++语言的具体缩进方式 | |
" set backspace=2 " 设置退格键可用 | |
set undofile " Persistent undo even through restart | |
set undodir=$HOME/.vim/undo | |
set undolevels=1000 | |
set undoreload=10000 | |
set mouse=a " Enable mouse usage (all modes) "使用鼠标 | |
set number " Enable line number "显示行号 | |
set relativenumber " Enable line number "显示行号 | |
:highlight ExtraWhitespace ctermbg=darkgreen guibg=lightgreen | |
" Match whitespace at end of line | space before tab | tab before space | space before text | |
":auto Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t\|\t\zs \+\|^\t*\zs \+\|^[^\*"]*\zs / | |
:auto Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t\|\t\zs \+/ | |
"--命令行设置-- | |
set showcmd " 命令行显示输入的命令 | |
set noshowmode | |
"-- omnicppcomplete setting -- | |
" 按下F3自动补全代码,注意该映射语句后不能有其他字符,包括tab;否则按下F3会自动补全一些乱码 | |
imap <F3> <C-X><C-O> | |
" 按下F2根据头文件内关键字补全 | |
imap <F2> <C-X><C-I> | |
set completeopt=menu,menuone " 关掉智能补全时的预览窗口 | |
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 | |
"-- echofunc -- | |
let g:EchoFuncShowOnStatus = 1 " to avoid echoing function name in message line. | |
"-- Taglist setting -- | |
let Tlist_Use_Right_Window=0 "让窗口显示在右边,0的话就是显示在左边 | |
let Tlist_Show_One_File=0 "让taglist可以同时展示多个文件的函数列表 | |
let Tlist_File_Fold_Auto_Close=1 "非当前文件,函数列表折叠隐藏 | |
let Tlist_Exit_OnlyWindow=1 "当taglist是最后一个分割窗口时,自动推出vim 是否一直处理tags.1:处理;0:不处理 | |
let Tlist_Process_File_Always=1 "实时更新tags | |
let Tlist_Inc_Winwidth=0 | |
"-- WinManager setting -- | |
"let g:winManagerWindowLayout='FileExplorer|TagList' " 设置我们要管理的插件 | |
let g:winManagerWindowLayout='TagList' " 设置我们要管理的插件 | |
"let g:persistentBehaviour=0 " 如果所有编辑文件都关闭了,退出vim | |
let g:winManagerWidth=36 | |
let g:defaultExplorer=0 | |
nmap wm :WMToggle<cr> | |
" -- MiniBufferExplorer -- | |
let g:miniBufExplMapWindowNavVim = 1 " 按下Ctrl+h/j/k/l,可以切换到当前窗口的上下左右窗口 | |
let g:miniBufExplMapWindowNavArrows = 1 " 按下Ctrl+箭头,可以切换到当前窗口的上下左右窗口 | |
let g:miniBufExplMapCTabSwitchBufs = 1 " 启用以下两个功能:Ctrl+tab移到下一个buffer并在当前窗口打开;Ctrl+Shift+tab移到上一个buffer并在当前窗口打开;ubuntu好像不支持 | |
"let g:miniBufExplMapCTabSwitchWindows = 1 "启用以下两个功能:Ctrl+tab移到下一个窗口;Ctrl+Shift+tab移到上一个窗口;ubuntu好像不支持 | |
let g:miniBufExplModSelTarget = 1 "不要在不可编辑内容的窗口(如TagList窗口)中打开选中的buffer | |
"--fold setting-- | |
set foldmethod=syntax " 用语法高亮来定义折叠 | |
set foldlevel=10 " 启动vim时不要自动折叠代码 | |
set foldcolumn=5 " 设置折叠栏宽度 | |
"-- Cscope setting -- | |
" .vim/plugin/cscope_map.vim | |
"-- genutils setting -- | |
command! -nargs=0 -range=% SortByLength <line1>,<line2>call QSort( | |
\ 'CmpByLineLengthNname', 1) | |
command! -nargs=0 -range=% RSortByLength <line1>,<line2>call QSort( | |
\ 'CmpByLineLengthNname', -1) | |
command! -nargs=0 -range=% SortJavaImports <line1>,<line2>call QSort( | |
\ 'CmpJavaImports', 1) | |
nnoremap <silent> <C-Space> :call ShiftWordInSpace(1)<CR> | |
nnoremap <silent> <C-BS> :call ShiftWordInSpace(-1)<CR> | |
nnoremap <silent> \cw :call CenterWordInSpace()<CR> | |
nnoremap <silent> \va :call AlignWordWithWordInPreviousLine()<CR> | |
command! -nargs=1 -bang -complete=customlist,genutils#UserFileComplete2 | |
\ FindInPath :find<bang> <args> | |
command! -nargs=* -complete=command Redir | |
\ :new | put! =GetVimCmdOutput('<args>') | setl bufhidden=wipe | | |
\ setl nomodified | |
augroup my-group | |
au! | |
au BufWritePost ~/.vimrc so ~/.vimrc | |
augroup END | |
"-- lookupfile -- | |
let g:LookupFile_MinPatLength = 4 | |
let g:LookupFile_PreserveLastPattern = 0 | |
let g:LookupFile_PreservePatternHistory = 1 | |
let g:LookupFile_AlwaysAcceptFirst = 1 | |
let g:LookupFile_AllowNewFiles = 0 | |
if filereadable(".cscopedb/.cscope.big.filetags") | |
let g:LookupFile_TagExpr = '".cscopedb/.cscope.big.filetags"' | |
elseif filereadable(".cscopedb/.cscope.big.files") | |
let s:cmd = "awk -F '/' '{printf \"\\%s\\t../\\%s\\t1\\n\", $NF, $0}' .cscopedb/.cscope.big.files > .cscopedb/.cscope.big.filetags" | |
silent execute "!" . s:cmd | |
let g:LookupFile_TagExpr = '".cscopedb/.cscope.big.filetags"' | |
endif | |
nmap <silent> <leader>lk :LUTags<cr> | |
nmap <silent> <leader>ll :LUBufs<cr> | |
nmap <silent> <leader>lw :LUWalk<cr> | |
" customized keyboard shortcuts | |
let mapleader="\<Space>" | |
nmap <tab> V> | |
nmap <s-tab> V< | |
vmap <tab> >gv | |
vmap <s-tab> <gv | |
nnoremap <silent> <Leader>j m`o<Esc>`` | |
nnoremap <silent> <Leader>k m`O<Esc>`` | |
nnoremap <silent> <Leader>1 :b1<CR> | |
nnoremap <silent> <Leader>2 :b2<CR> | |
nnoremap <silent> <Leader>3 :b3<CR> | |
nnoremap <silent> <Leader>4 :b4<CR> | |
nnoremap <silent> <Leader>5 :b5<CR> | |
nnoremap <silent> <Leader>6 :b6<CR> | |
nnoremap <silent> <Leader>7 :b7<CR> | |
nnoremap <silent> <Leader>8 :b8<CR> | |
nnoremap <silent> <Leader>` :b#<CR> | |
nnoremap <silent> <Leader>w :w<CR> | |
nnoremap <silent> <Leader>q :q<CR> | |
nnoremap <silent> <Leader>x :x<CR> | |
nnoremap <silent> <Leader>c :call P4_check_out_current_file()<CR> | |
vmap <silent> <Leader>y "+y | |
nnoremap <silent> <Leader>p "+p | |
vmap <silent> <Leader>p "+p | |
nnoremap <CR> G | |
nnoremap <F6> :GundoToggle<CR> | |
"nnoremap <silent> <Leader>s :cs f s | |
"nnoremap <silent> <Leader>g :cs f g | |
let g:cscopedb_auto_init=2 | |
let g:cscopedb_auto_files=1 | |
let g:cscopedb_src_dirs_file="./.quantenna_sdk_src_dirs" | |
function! Cscope_dynamic_update_hook(flag) | |
if a:flag == 0 | |
echom "Dynamic cscope database update completed" | |
else | |
echom "Dynamic cscope database update starting..." | |
endif | |
endfunction | |
function! P4_check_out_current_file() | |
let s:file = resolve(expand("%")) | |
call system('p4 -c $P4CLIENT edit '.s:file) | |
endfunction | |
" I haven't found how to hide this function (yet) | |
function! RestoreRegister() | |
let @" = s:restore_reg | |
return '' | |
endfunction | |
function! s:Repl() | |
let s:restore_reg = @" | |
return "p@=RestoreRegister()\<cr>" | |
endfunction | |
" NB: this supports "rp that replaces the selection by the contents of @r | |
vnoremap <silent> <expr><Plug>p <sid>Repl() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment