標籤:補全功能 style include efk sea find number -o nmap
最近由於各種原因,IDE從source insight換成了vim,參考了諸多部落格的文章,折騰了好久折騰了個大概的樣子,現在總結一下經驗:
主要參考:
改造vim變成source insight
Winxp下 gvim 編程環境搭建
VIM學習筆記 摺疊 (Fold)
:
1. 安裝:
下載gvim8.0安裝就可以了
剛裝完是這個樣子的:
2. 外掛程式安裝:
選用的外掛程式如下表
外掛程式名 |
作用 |
|
安裝方法(vimrc在後面統一配置) |
taglist |
基於ctags的taglist |
http://www.vim.org/scripts/script.php?script_id=273 |
解壓到.\vim80目錄下面 |
WinManager |
將FileExplore和Taglist整合 |
http://www.vim.org/scripts/script.php?script_id=95 |
解壓到.\vim80目錄下面 |
Ctags |
ctags,用於產生tag檔案(符號連結) |
http://ctags.sourceforge.net |
將ctags.exe放到.\vim80路徑下,並將vim80添加到環境變數/ctags.exe放到system32路徑下 |
Snipmate |
提供常用代碼快速輸入(Tab補齊) |
http://www.vim.org/scripts/script.php?script_id=2540 |
解壓到.\vimfiles目錄下面 |
Supertab |
用Tab鍵自動補齊 |
http://www.vim.org/scripts/script.php?script_id=1643 |
Open the file in vim ($ vim supertab.vmb) Source the file (:so %) |
SrcExpl |
實現source insight的預覽框的功能 |
http://www.vim.org/scripts/script.php?script_id=2179 |
解壓到.\vimfiles目錄下面 |
Cscope |
ctags的強化版,不僅可以產生源tag還能產生調用tag |
http://sourceforge.net/projects/mslk/files/ |
將壓縮包解壓並將目錄加入環境變數path中 |
3. 主題安裝:
vim主題選用monokai,字型選用consolas
主題地址:https://github.com/sickill/vim-monokai
變更檔名為monokai.vim後放到vim80\colors\裡
個人喜好的一些修改:(修改到monokai.vim對應的行)
hi Search term=reverse cterm=NONE ctermfg=231 ctermbg=24 gui=NONE guifg=#f8f8f2 guibg=#AA0000hi Folded ctermfg=242 ctermbg=235 cterm=NONE guifg=#75715e guibg=#272822 gui=NONEhi FoldColumn ctermfg=242 ctermbg=235 cterm=NONE guifg=#75715e guibg=#272822 gui=NONE
4.vimrc更改:
在_vimrc檔案後增加如下:
"設定Taglistlet Tlist_Show_One_File=1let Tlist_Exit_OnlyWindow=1"使用F8開啟Taglist"nmap <F8> :TlistToggle<CR>"使用F8開啟wimManager(FileExplorer+TagList)let g:winManagerWindowLayout=‘FileExplorer|TagList‘nmap <F8> :WMToggle<cr>"使用F9開啟SrcExplnmap <F9> :SrcExplToggle<CR>let g:SrcExpl_jumpKey = "<ENTER>" let g:SrcExpl_gobackKey = "<SPACE>" let g:SrcExpl_prevDefKey = "<F3>" let g:SrcExpl_nextDefKey = "<F4>" "設定SuperTab,用tab鍵開啟cppcomplet的自動補全功能。let g:SuperTabRetainCompletionType=2let g:SuperTabDefaultCompletionType="<C-X><C-O>""顯示行號set number"設定主題顏字型colorscheme monokaiset guifont=Consolas:h12"為了使用智能補全,開啟檔案類型檢測,關閉VI相容模式filetype plugin indent onset nocp"字元匹配單詞set incsearch"程式碼摺疊功能set fdm=syntaxset foldlevel=1set foldcolumn=2
按F9開啟Source Explore,F8開啟WindowManager
cscope設定:(我沒用到)
詳見:http://cscope.sourceforge.net/cscope_maps.vim
"cscopenmap <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>
5. 一些其他設定:
tags產生(雖然Source Explore支援每次開啟調用時更新,但如果首次開啟沒有tags會在目前的目錄產生,如果開啟的是工程內部檔案就會導致tags不全,所以首次運行最好產生一下)
ctags -R ./Drvlib ./Source ./Include
cscope資料庫產生(路徑更改為自己的)
find -P ./Drvlib ./Source ./Include > cscope.filescscope -bq
cscope資料庫包含(路徑更改為自己的)
cscope add ..\cscope.out
windows下 gvim8.0 編譯器配置