~/.vimrc config
1 runtime! debian.vim 2 "设置编码 3 set encoding=utf-8 4 set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 5 set fileencodings=utf-8,ucs-bom,chinese 6 7 "语言设置 8 set langmenu=zh_CN.UTF-8 9 10 "设置语法高亮 11 syntax enable 12 syntax on 13 14 "设置配色方案 15 colorscheme torte 16 17 "可以在buffer的任何地方使用鼠标 18 set mouse=a 19 set selection=exclusive 20 set selectmode=mouse,key 21 22 "高亮显示匹配的括号 23 set showmatch 24 25 "去掉vi一致性 26 set nocompatible 27 28 "设置缩进 29 set tabstop=4 30 set softtabstop=4 31 set shiftwidth=4 32 set autoindent 33 set cindent 34 if &term=="xterm" 35 set t_Co=8 36 set t_Sb=^[[4%dm 37 set t_Sf=^[[3%dm 38 endif 39 40 "打开文件类型自动检测功能 41 filetype on 42 43 "设置taglist 44 let Tlist_Show_One_File=0 "显示多个文件的tags 45 let Tlist_File_Fold_Auto_Close=1 "非当前文件,函数列表折叠隐藏 46 let Tlist_Exit_OnlyWindow=1 "在taglist是最后一个窗口时退出vim 47 let Tlist_Use_SingleClick=1 "单击时跳转 48 let Tlist_GainFocus_On_ToggleOpen=1 "打开taglist时获得输入焦点 49 let Tlist_Process_File_Always=1 "不管taglist窗口是否打开,始终解析文件中的tag 50 51 "设置WinManager插件 52 let g:winManagerWindowLayout='FileExplorer|TagList' 53 nmap wm :WMToggle<cr> 54 map <silent> <F9> :WMToggle<cr> "将F9绑定至WinManager,即打开WimManager 55 56 "设置CSCOPE 57 set cscopequickfix=s-,c-,d-,i-,t-,e- "设定是否使用quickfix窗口显示cscope结果 58 59 "设置Grep插件 60 nnoremap <silent> <F3> :Grep<CR> 61 62 "设置一键编译 63 map <F6> :make<CR> 64 65 "设置自动补全 66 filetype plugin indent on "打开文件类型检测 67 set completeopt=longest,menu "关掉智能补全时的预览窗口 68 69 "启动vim时如果存在tags则自动加载 70 if exists("tags") 71 set tags=./tags 72 endif 73 74 "设置按F12就更新tags的方法 75 map <F12> :call Do_CsTag()<CR> 76 nmap <C-@>s :cs find s <C-R>=expand("<cword>")<CR><CR>:copen<CR> 77 nmap <C-@>g :cs find g <C-R>=expand("<cword>")<CR><CR> 78 nmap <C-@>c :cs find c <C-R>=expand("<cword>")<CR><CR>:copen<CR> 79 nmap <C-@>t :cs find t <C-R>=expand("<cword>")<CR><CR>:copen<CR> 80 nmap <C-@>e :cs find e <C-R>=expand("<cword>")<CR><CR>:copen<CR> 81 nmap <C-@>f :cs find f <C-R>=expand("<cfile>")<CR><CR>:copen<CR> 82 nmap <C-@>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>:copen<CR> 83 nmap <C-@>d :cs find d <C-R>=expand("<cword>")<CR><CR>:copen<CR> 84 function Do_CsTag() 85 let dir = getcwd() 86 if filereadable("tags") 87 if(g:iswindows==1) 88 let tagsdeleted=delete(dir."\\"."tags") 89 else 90 let tagsdeleted=delete("./"."tags") 91 endif 92 if(tagsdeleted!=0) 93 echohl WarningMsg | echo "Fail to do tags! I cannot delete the tags" | echohl None 94 return 95 endif 96 endif 97 98 if has("cscope") 99 silent! execute "cs kill -1" 100 endif 101 102 if filereadable("cscope.files") 103 if(g:iswindows==1) 104 let csfilesdeleted=delete(dir."\\"."cscope.files") 105 else 106 let csfilesdeleted=delete("./"."cscope.files") 107 endif 108 if(csfilesdeleted!=0) 109 echohl WarningMsg | echo "Fail to do cscope! I cannot delete the cscope.files" | echohl None 110 return 111 endif 112 endif 113 114 if filereadable("cscope.out") 115 if(g:iswindows==1) 116 let csoutdeleted=delete(dir."\\"."cscope.out") 117 else 118 let csoutdeleted=delete("./"."cscope.out") 119 endif 120 if(csoutdeleted!=0) 121 echohl WarningMsg | echo "Fail to do cscope! I cannot delete the cscope.out" | echohl None 122 return 123 endif 124 endif 125 126 if(executable('ctags')) 127 "silent! execute "!ctags -R --c-types=+p --fields=+S *" 128 silent! execute "!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q ." 129 endif 130 131 if(executable('cscope') && has("cscope") ) 132 if(g:iswindows!=1) 133 silent! execute "!find . -name '*.h' -o -name '*.c' -o -name '*.cpp' -o -name '*.java' -o -name '*.cs' > cscope.files" 134 else 135 silent! execute "!dir /s/b *.c,*.cpp,*.h,*.java,*.cs >> cscope.files" 136 endif 137 silent! execute "!cscope -b" 138 execute "normal :" 139 140 if filereadable("cscope.out") 141 execute "cs add cscope.out" 142 endif 143 endif 144 endfunction 145 146 "设置默认shell 147 set shell=bash 148 149 "设置VIM记录的历史数 150 set history=400 151 152 "设置当文件被外部改变的时侯自动读入文件 153 if exists("&autoread") 154 set autoread 155 endif 156 157 "设置ambiwidth 158 set ambiwidth=double 159 160 "设置文件类型 161 set ffs=unix,dos,mac 162 163 "设置增量搜索模式 164 set incsearch 165 166 "设置静音模式 167 set noerrorbells 168 set novisualbell 169 set t_vb= 170 171 "不要备份文件 172 set nobackup 173 set nowb