1、安裝gvim73_46.exe
2、安裝中文幫助vimcdoc-1.5.0-setup.exe;
在_vimrc中添加
if version >= 603
set helplang=cn
endif
3、安裝ctags
(1)将ctags58.zip解壓到..\vim73\下
(2)設定環境變量:
GVim = f:\Program Files\Vim\vim73\ctags58\
Path中加上;%GVim%
如果不管用就添加到使用者變量中
(3)在_vimrc中添加
set tags=tags;
set autochdir
備注: ctags的作用是抽取源代碼的符号,用來支援函數定義查找等...;
抽取符号的指令是:在GVim中打開某檔案a.cpp後,執行:!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .,便會在a.cpp所在目錄生成tags檔案;所有檔案的符号都 會放在一個tags檔案中
4、安裝taglist
(1)将taglist_45.zip解壓,解壓後包含一個doc檔案夾和一個plugin檔案夾,将其中内容分别複制到vim73下的doc及plugin中。
(2)在_vimrc中添加
let Tlist_Auto_Open = 1
let Tlist_Exit_OnlyWindow = 1
(3)修改..\Vim73\plugin\taglist.vim檔案,
将
let ctags_cmd = '"' . s:taglist_tempfile . '"'
改為
let ctags_cmd = '"' . ctags_cmd . '"'
備注:taglist配合ctags使用,它将ctags生成的符号以清單的形式在視窗中列出,其中第2步Tlist_Ctags_Cmd是指定ctags的位置,
第3步是為了解決一個問題:當檔案在中文目錄下時,taglist解析不到ctags的路徑。
5、設定文法高亮、顔色、行号
在_vimrc中添加:
set nu!
colorscheme desert
syntax enable
syntax on
6、高亮函數名稱
在..\Vim74\syntax下找到c.vim和cpp.vim,均添加如下内容:
syn match cFunction "\<[a-zA-Z_][a-zA-Z_0-9]*\>[^()]*)("me=e-2
syn match cFunction "\<[a-zA-Z_][a-zA-Z_0-9]*\>\s*("me=e-1
hi cFunction gui=NONE guifg=#B5A1FF
7、安裝winmanager
(1)将winmanager.zip解壓,解壓後包含一個doc檔案夾和一個plugin檔案夾,将其中内容分别複制到vim73下的doc及plugin中。
(2)在_vimrc中添加:
let g:winManagerWindowLayout = "FileExplorer|TagList"
let g:winManagerWidth = 30
let g:defaultExplorer = 0
let g:AutoOpenWinManager = 1
map <c-w><c-f> :FirstExplorerWindow<cr>
map <c-w><c-b> :BottomExplorerWindow<cr>
map <c-w><c-t> :WMToggle<cr>
(3)在..\Vim73\plugin\winmanager.vim中添加
"set auto open Winmanager
if g:AutoOpenWinManager
autocmd VimEnter * nested call s:StartWindowsManager()|1wincmd w
endif
備注:winmanager用來顯示目前目錄的所有檔案清單
8、安裝minibuffexplorer
(1)将minibuffexplorer.vim複制到Vim73\plugin中
(2)在_vimrc中添加:
let g:miniBufExplMapCTabSwitchBufs=1
let g:miniBufExplMapWindowsNavVim=1
let g:miniBufExplMapWindowNavArrows=1
備注:minibuffexplorer類似于标簽頁,ctrl+ww到minibuffer視窗,tab鍵改變選中的檔案,回車打開選中的檔案,此時minibuffer視窗變大,再次ctrl+ww到minibuffer視窗,tab鍵改變選中的檔案,回車打開選中的檔案,此時minibuffer視窗變小,之後ctrl+tab可以切換多個檔案
9、安裝a.vim
(1)将a.vim複制到Vim73\plugin中
(2)在_vimrc中添加
nnoremap <silent> <F12> :A<CR>
備注:使用:A或F12在頭檔案/源檔案間切換
10、打開時最大化
在_vimrc中添加
au GUIENTER * simalt ~x
11、類成員自動補齊
把omnicppcomplete-0.41的三個檔案夾解壓到VimFiles檔案夾下面即可。
注:單獨使用!ctags -R不行,必須使用!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .生成符号
12、
set tabstop=4 "讓一個tab等于4個空格
set nowrap "不自動換行
13、自動補齊括号
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap { {<CR>}<ESC>O
:inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i
function ClosePair(char)
if getline('.')[col('.') - 1] == a:char
return ""
else
return a:char
endif
endfunction
14、禁止自動備份
在vim73目錄下找到vimrc_example.vim,找到
"else
" set backup " keep a backup file
注釋掉。
備注:在Total Commander中利用F4,使得GVim隻運作一個執行個體F:\Program Files\Vim\vim73\gvim.exe --remote-tab-silent
如果使用exVim的話, 使用F:\Program Files\Vim\vim73\gvim.exe --remote-silent
另外exVim安裝的時候不要放在Program Files中,最好按照其預設的路徑,文檔中是這麼說的。
Vim與外界進行複制粘貼需要使用系統粘貼闆,方法是按v進入可視模式,然後選中要複制的文本,再按"+y。注意是小寫y;粘貼則是"+p