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

  

 

posted @ 2018-04-30 17:51  Elf.a  阅读(3513)  评论(3编辑  收藏  举报