windows下 gvim8.0 編譯器配置


最近由於各種原因,IDE從source insight換成了vim,參考了諸多博客的文章,折騰了好久折騰了個大概的樣子,現在總結一下經驗:

主要參考:

改造vim變成source insight

Winxp下 gvim 編程環境搭建

VIM學習筆記 折疊 (Fold)

效果圖(新:Taglist+NERD_Tree+SrcExpl),圖為自動補全狀態:

 

 

效果圖(舊:WinManager+SrcExpl):

 

 

 

1. 安裝:

下載gvim8.0安裝就可以了

剛裝完是這個樣子的:

 

2. 插件安裝:

選用的插件如下表 (嘗試后發現WinManager和SrcExpl沖突,改用Trinity)

插件名

作用

下載地址

 安裝方法(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中

Trinity

NERD_Tree+taglist+SrcExpl的組合版

http://www.vim.org/scripts/script.php?script_id=2347

解壓到.\vimfiles目錄下面

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=#AA0000
hi Folded ctermfg=242 ctermbg=235 cterm=NONE guifg=#75715e guibg=#272822 gui=NONE
hi FoldColumn ctermfg=242 ctermbg=235 cterm=NONE guifg=#75715e guibg=#272822 gui=NONE

  

4.vimrc更改:

 在_vimrc文件后增加如下:

"設置Taglist
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1

"使用F8打開Taglist
"nmap <silent> <F8> :TlistToggle<CR>
"通過WinManager插件來將TagList窗口和netrw窗口整合起來
let g:winManagerWindowLayout='FileExplorer|TagList'
"nmap <F8> :WMToggle<cr>
"使用F9打開SrcExpl
"nmap <F9> :SrcExplToggle<CR>

"Trinity 設置
" Open and close all the three plugins on the same time 
nmap <F8>   :TrinityToggleAll<CR> 
" Open and close the srcexpl.vim separately 
nmap <F9>   :TrinityToggleSourceExplorer<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=2
let g:SuperTabDefaultCompletionType="<C-X><C-O>"
"顯示行號
set number
"設置主題顏字體
colorscheme monokai
set guifont=Consolas:h12
"為了使用智能補全,打開文件類型檢測,關閉VI兼容模式
filetype plugin indent on
set nocp
"字符匹配單詞
set incsearch
"代碼折疊
set fdm=syntax
set foldlevel=1
set foldcolumn=2
"不換行
set nowrap
"縮進設置
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
set softtabstop=4

  

F8開啟全部插件,F9開關SrcExpl(Trinity版)

Winmanager的設置被注視掉了(發現和SrcExpl沖突)

cscope設置:(我沒用到)

詳見:http://cscope.sourceforge.net/cscope_maps.vim

"cscope
nmap <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.files
cscope -bq

cscope數據庫包含(路徑更改為自己的)

cscope add ..\cscope.out

  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM