我的VIM配置

来源:互联网 发布:程序员自我评价怎么写 编辑:程序博客网 时间:2024/04/30 11:29

" My Normal Setup
syntax enable " 打开语法高亮
syntax on " 开启文件类型侦测
set mouse=nvih " 使用鼠标
" set number " 显示行号
set expandtab " 展开Tab键为空格键
set autoindent " 即每行的缩进值与上一行相等;使用 noautoindent 取消设置
" set smartindent " 智能对齐方式
set shiftwidth=4 " (自动) 缩进使用的4个空格
" set cindent " 使用 C/C++ 语言的自动缩进方式
" set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s "设置C/C++语言的具体缩进方式
set showmatch " 设置匹配模式,显示匹配的括号
set linebreak " 整词换行
set whichwrap=b,s,<,>,[,] " 光标从行首和行末时可以跳到另一行去
set history=50 "历史记录50条
set laststatus=2 " 总显示最后一个窗口的状态行;设为1则窗口数多于一个的时候显示最后一个窗口的状态行;0不显示最后一个窗口的状态行
set ruler " 标尺,用于显示光标位置的行号和列号,逗号分隔。每个窗口都有自己的标尺。如果窗口有状态行,标尺在那里显示。否则,它显示在屏幕的最后一行上。
set incsearch " 输入字符串就显示匹配点
set hlsearch " 高亮显示搜索结果
set showcmd " 命令行显示输入的命令
set showmode " 命令行显示vim当前模式
set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\ 
"set shiftwidth=4 " 设定 << 和 >> 命令移动时的宽度为 4
set softtabstop=4 " 使得按退格键时可以一次删掉 4 个空格
"set tabstop=4 " 设定 tab 长度为 4
"set autochdir " 自动切换当前目录为当前文件所在的目录
set ignorecase smartcase " 搜索时忽略大小写,但在有一个或以上大写字母时仍保持对大小写敏感
set hidden " 允许在有未保存的修改时切换缓冲区,此时的修改由 vim 负责保存
filetype indent on " 针对不同的文件类型采用不同的缩进格式
filetype plugin on " 针对不同的文件类型加载对应的插件
filetype plugin indent on " 启用自动补全
" My Hotkey Setup
" 切换标签页
nmap <F3> :tabn<CR>
nmap <F4> :tabp<CR>
" 更新ctags, cscope库
function UpdateTags()
    :wa
    :!ctags -R *;cscope -Rbq
    :cs reset
    :cs add cscope.out
endfunc
nmap <F7> :call UpdateTags()<CR><CR>
" 编译
function CompileAllSources()
    :wa
    :make
    :cw
endfunc
nmap <F8> :call CompileAllSources()<CR><CR><CR>
" Quickfix 窗口快捷键
nmap <C-n> :cnext<CR>
nmap <C-p> :cprev<CR>
" CTags 快捷键
nmap <S-n> :tnext<CR>
nmap <S-p> :tprev<CR>
" My cscope Setup
if has("cscope")
    cs add cscope.out
    set cscopequickfix=s-,c-,d-,i-,t-,e-
    nmap <F2> :cs find f <C-R>=expand("<cfile>")<CR><CR>
    nmap <F5> :cs find c <C-R>=expand("<cword>")<CR><CR>
    nmap <F6> :cs find s <C-R>=expand("<cword>")<CR><CR>
endif

" 不同时显示多个文件的 tag ,只显示当前文件的
let Tlist_Show_One_File=1
" 如果 taglist 窗口是最后一个窗口,则退出 vim
let Tlist_Exit_OnlyWindow=1
let g:winManagerWindowLayout='TagList'
nmap wm :WMToggle<CR>


" Buffer Explorer
nmap _ \be

" 创建文件列表便于cs find -f 跳转
function Buildfilelist()
    if filereadable("filelist.txt")
    else
        :! echo "building filelist.txt please wait..."
        :! sudo find . -regex '.*\.h\|.*\.c\|.*\.cpp' -exec basename {} \; > filelist.txt
        :! sudo chmod a+w ./filelist.txt
    endif
    :e ./filelist.txt
endfunc
nmap + :call Buildfilelist() <CR><CR><CR><CR>

" 设置预览当前符号
nmap <C-\> :ptag <C-R>=expand("<cword>")<CR><CR>

" 关闭所有辅助窗口
function CloseAllTooktipWindow()
    :cclose
    :pclose
endfunc
nmap <space> :call CloseAllTooktipWindow() <CR>

" 设置编码
set fileencodings=utf-8,gb2312,gbk,gb18030
set termencoding=utf-8,gb2312,gbk,gb18030


0 0