我的vim配置文件.vimrc

时间:2021-07-25 08:26:26

我的vim配置文件.vimrc

map <silent> <F10> :TlistToggle<cr>
map <silent> <F8> :TMiniBufExplorer<cr>
map <silent> <F9> :WMToggle<cr>
map <silent> <F4> :bp<cr>
map <silent> <F5> :bn<cr>
"map <C-f> :q<cr>
"map <C-i> :w<cr>
"map <C-a> :x<cr>
nnoremap <silent> <F12> :A<CR>
nnoremap <silent> <F3> :Grep<CR>
"taglist
let g:Tlist_Show_One_File=1
let g:Tlist_Exit_OnlyWindow=1
"let g:Tlist_File_Fold_Auto_Close=1

let g:AutoOpenWinManager = 1
let g:winManagerWindowLayout='FileExplorer|TagList'
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:SuperTabDefaultCompletionType="context"
let g:SuperTabRetainCompletionType=2
let g:SuperTabDefaultCompletionType="<C-X><C-O>"
let g:bufExplorerMaxHeight=30

let OmniCpp_MayCompleteDot = 1   " 输入 .  后自动补全
let OmniCpp_MayCompleteArrow = 1 " 输入 -> 后自动补全
let OmniCpp_MayCompleteScope = 1

"let g:miniBufExplorerMoreThanOne=0

let g:winManagerWidth = 25
set nocp
filetype plugin on
set completeopt=longest,menu
syntax enable
syntax on
colorscheme default
"colorscheme desert
set cscopequickfix=s-,c-,d-,i-,t-,e-

nmap <C-_>s :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>g :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>c :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>t :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>e :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-_>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-_>i :cs find i ^<C-R>=expand("<cfile>")<CR><CR>
nmap <C-_>d :cs find d <C-R>=expand("<cword>")<CR><CR>
"cscope快捷方式

set mouse=a    "设置可以鼠标操作
set nu
set tabstop=4     "设置制表符宽度为4
set softtabstop=4 "设置(软)制表符宽度为4
set shiftwidth=4  "设置缩进的空格数为4
set autoindent    "设置自动缩进:即每行的缩进值与上一行相等;使用 noautoindent 取消设置
set cindent       "设置 使用 C/C++ 语言的自动缩进方式
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s  "设置C/C++语言的具体缩进方式(以我的windows风格为例)
let &termencoding=&encoding
set fileencodings=utf-8,gbk,cp936,big5,ucs-bom   "设置语言编码支持

"set tags=./tags,~/.vim/tags/linux/ctags/tags,../deps/libzs/tags   "设置tags文件路径

set fdm=syntax  "设置折叠方式
set foldcolumn=0 " 设置折叠区域的宽度
"set foldclose=all " 设置为自动关闭折叠
setlocal foldlevel=1 " 设置折叠层数为
set foldlevelstart=99 "打开文件默认不折叠
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zC' : 'zO')<CR>
"用空格键来开关折叠

hi Comment ctermfg =darkcyan
"设置注释字体颜色

set clipboard+=unnamed
" 与windows共享剪贴板

hi Folded guibg=black guifg=grey40 ctermfg=grey ctermbg=darkgrey
hi FoldColumn guibg=black guifg=grey20 ctermfg=4 ctermbg=7
"设置折叠颜色

au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
"vim打开时在上次光标的位置

set wildmenu
"命令窗口列表

"Smart way to move btw. window
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l

"F11生成/更新tags文件
set tags=tags;
set autochdir
function! UpdateTagsFile()
    silent !ctags -R --fields=+ianS --extra=+q
    endfunction
nmap <F11> :call UpdateTagsFile()<CR>
    
"Ctrl + F12删除tags文件
function! DeleteTagsFile()
   "Linux下的删除方法
   silent !rm tags
   "Windows下的删除方法
   silent !del /F /Q tags
endfunction
nmap <C-F11> :call DeleteTagsFile()<CR>
"退出VIM之前删除tags文件
"au VimLeavePre * call DeleteTagsFile()