在用户目录新建.vimrc文件:vim ~/.vimrc内容如下:"设置编码"set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936set termencoding=utf-8set encoding=utf-8"显示行号"set nuset number"突出显示当前行"set cursorlineset cc=0"启用鼠标"set mouse=aset mouse=vset selection=exclusiveset selectmode=mouse,key"显示括号匹配"set showmatch"设置Tab长度为4空格"set tabstop=4"设置自动缩进长度为4空格"set shiftwidth=4"继承前一行的缩进方式,适用于多行注释"set autoindentset pasteset listchars=tab:>-,trail:-"总是显示状态栏"set laststatus=2"显示光标当前位置"set ruler"-- Cscope setting --if has("cscope")" 指定用来执行cscope的命令set csprg=/usr/bin/cscope" 设置cstag命令查找次序:0先找cscope数据库再找标签文件;1先找标签文件再找cscope数据库set csto=0" 同时搜索cscope数据库和标签文件set cst" 使用QuickFix窗口来显示cscope查找结果set cscopequickfix=s-,c-,d-,i-,t-,e-set nocsverb" 若当前目录下存在cscope数据库,添加该数据库到vimif filereadable("cscope.out")cs add cscope.out" 否则只要环境变量CSCOPE_DB不为空,则添加其指定的数据库到vimelseif $CSCOPE_DB != ""cs add $CSCOPE_DBendifset csverbendifmap <F4> :cs add ./cscope.out .<CR><CR><CR> :cs reset<CR>imap <F4> <ESC>:cs add ./cscope.out .<CR><CR><CR> :cs reset<CR>"打开文件类型检测功能"filetype on "设定系统中ctags程序的位置let Tlist_Ctags_Cmd = "/usr/bin/ctags""不同时显示多个文件的tag,只显示当前文件的let Tlist_Show_One_File = 1"如果taglist窗口是最后一个窗口,则退出vimlet Tlist_Exit_OnlyWindow = 1let Tlist_Use_Right_Window = 1"按F7等同于在命令行模式输入:TlistTogglemap <silent> <F7> :TlistToggle<cr>nmap <C-H> <C-W>hnmap <C-J> <C-W>jnmap <C-K> <C-W>knmap <C-L> <C-W>l" // The switch of the Source Explorernmap <F8> :SrcExplToggle<CR>" // Set the height of Source Explorer windowlet g:SrcExpl_winHeight = 8" // Set 100 ms for refreshing the Source Explorerlet g:SrcExpl_refreshTime = 100" // Set "Enter" key to jump into the exact definition contextlet g:SrcExpl_jumpKey = "<ENTER>"" // Set "Space" key for back from the definition contextlet g:SrcExpl_gobackKey = "<SPACE>"nmap <F9> :NERDTreeToggle<CR>let NERDTreeWinPos = "left"
