天天看點

Winxp下 gvim 程式設計環境搭建

Winxp下 gvim 程式設計環境搭建

 

1.官方網站下載下傳最新的gvim7.1 win32,然後選擇完全安裝;我是安裝在d:/vim目錄下面,安裝後的目錄結構如下:

D:/VIM

├─vim71

│ ├─autoload

│ ├─colors

│ ├─compiler

│ ├─doc

│ ├─ftplugin

│ ├─indent

│ ├─keymap

│ ├─lang

│ ├─macros

│ ├─plugin

│ ├─spell

│ ├─syntax

│ ├─tools

│ └─tutor

└─vimfiles

├─after

├─autoload

├─colors

├─compiler

├─doc

├─ftdetect

├─ftplugin

├─indent

├─keymap

├─plugin

└─syntax

2.安裝常用插件:

vimdoc http://vcd.gro.clinux.org    (中文)

安裝 直接安裝即可,安裝時會自動搜尋到vim的安裝位置,然後安裝到相應的目錄

使用 :h

說明 中文幫助文檔

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

安裝 解壓到vim71目錄下面

使用 :Tlist

說明 需要Ctags産生的tags檔案配合

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

安裝 解壓到vim71目錄下面

使用 wm,這個指令是通過在_vimrc中配置後才能有,具體配置見後面的_vimrc檔案

說明 此插件的作用是将TagList視窗和netrw視窗整合起來

Ctags http://ctags.sourceforge.net

安裝 解壓到vim71目錄下面

使用 ctags -R --c++-kinds=+p --fields=+iaS --extra=+q src

在對C++檔案進行補全時,OmniCppComplete插件需要在标簽檔案中包含C++的額外資訊,是以上面的ctags指令不同于以前我們所使用的,它專門為C++語言生成一些額外的資訊.

說明 其實隻是一個ctags.exe檔案,用來産生tags檔案供其它插件使用

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

安裝 将minibufexpl.vim放 到vim71/plugin 檔案夾中即可;

使用 打開多個檔案後,自動在頂端出現檔案标簽,輕按兩下滑鼠或者Ctrl+tab鍵可以切換檔案;

說明  

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

安裝 将grep.vim放 到vim71/plugin 檔案夾中即可;

使用 安裝後會在菜單=》工具中增加search子菜單,也可以用指令:grep或者按照後面給出的_vimrc檔案映射快捷鍵F3

說明 需要windows版本的grep.exe程式配合;

到http://unxutils.sourceforge.net/下載下傳unxutils工具包裡面包含grep.exe,把grep.exe放到系統c:/windows/system32下面即可。

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

安裝 解壓到vimfiles目錄下面;

使用 配合後面的supertab插件,使用Tab鍵進行自動完成;

說明 如果要對c++檔案進行自動完成,需要生成tag檔案時用特殊的選項,見後面的_vimrc配置檔案

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

安裝 将a.vim放 到vim71/plugin 檔案夾中即可;

使用 :A

說明 在源檔案和頭檔案之間進行切換

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

安裝 将supertab.vim放 到vim71/plugin 檔案夾中即可;

使用 配合前面的omnicppcomplete插件,使用Tab鍵進行自動完成;

說明  

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

安裝 解壓到vim71目錄下面

使用 http://xiaobo.spaces.live.com/blog/cns!5ec21dee9b73c1a8!814.entry

說明  

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

安裝 解壓到vimfiles目錄下面;

使用 根據後面的_vimrc配置檔案,使用F5鍵打開搜尋視窗;Tab鍵進行選擇

說明 依賴于插件genutils

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

安裝 解壓到vimfiles目錄下面;

使用 這個插件提供了一些通用的函數,可供其它的腳本使用

說明 供lookupfile插件使用

clearcase https://p-blog.csdn.net/images/p_blog_csdn_net/minico/EntryImages/20081123/gvim.JPG

安裝 解壓到vimfiles目錄下面;

使用 這個插件提供一些常用的clearcase指令

說明 無

3._vimrc配置檔案

set nocompatible

source $VIMRUNTIME/vimrc_example.vim

source $VIMRUNTIME/mswin.vim

behave mswin

set diffexpr=MyDiff()

function MyDiff()

  let opt = '-a --binary '

  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif

  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif

  let arg1 = v:fname_in

  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif

  let arg2 = v:fname_new

  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif

  let arg3 = v:fname_out

  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif

  let eq = ''

  if $VIMRUNTIME =~ ' '

    if &sh =~ '/<cmd'

      let cmd = '""' . $VIMRUNTIME . '/diff"'

      let eq = '"'

    else

      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '/diff"'

    endif

  else

    let cmd = $VIMRUNTIME . '/diff'

  endif

  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq

endfunction

"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

" Add by minico---begin

"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

"設定幫助語言

set helplang=cn,en

"把gui的工具欄去掉(要去掉,把等号前面的加号變成一個減号即可)

set guioptions+=T

"把gui的右邊的滑動條去掉

set guioptions+=r

"把gui的左邊的滑動條去掉

set guioptions-=L

"把gui的菜單去掉

set guioptions+=m

filetype on

let Tlist_Show_Menu = 1

" 這項必須設定,否則出錯,配置taglist的ctags路徑

"let Tlist_Ctags_Cmd = 'D:/Vim/vim71/ctags.exe'

"設定Taglist

let Tlist_Show_One_File=1

let Tlist_Exit_OnlyWindow=1

" 使用F8打開Taglist

nnoremap <silent> <F8> :TlistToggle<CR>

"設定視窗大小和位置

set lines=80

set columns=200

winpos 0 0

"設定tags檔案路徑

set tags=G:/lwip/tags

"設定檔案浏覽器視窗顯示方式

"通過WinManager插件來将TagList視窗和netrw視窗整合起來

let g:winManagerWindowLayout='FileExplorer|TagList'

nmap wm :WMToggle<cr>

"設定SuperTab,用tab鍵打開cppcomplet的自動補全功能。

let g:SuperTabRetainCompletionType=2

let g:SuperTabDefaultCompletionType="<C-X><C-O>"

"顯示行号

set number

"打開文法高亮顯示功能

syntax enable

syntax on

"設定主題顔色

colorscheme desert

"則可以用<C-h,j,k,l>切換到上下左右的視窗中去

let g:miniBufExplMapWindowNavVim = 1

"按F12時在一個新的buffer中打開c/h檔案

nnoremap <silent> <F12> :A<CR>

"用F3調用grep查找目前光标所在處的字元串

nnoremap <silent> <F3> :Grep<CR>

"為了使用智能補全,打開檔案類型檢測,關閉VI相容模式

filetype plugin indent on

set nocp

"關掉智能補全時的預覽視窗,這樣可以防止閃屏現象

set completeopt=longest,menu

"====================Lookupfile 相關設定========================================

let g:LookupFile_MinPatLength = 2               "最少輸入2個字元才開始查找

let g:LookupFile_PreserveLastPattern = 0        "不儲存上次查找的字元串

let g:LookupFile_PreservePatternHistory = 1     "儲存查找曆史

let g:LookupFile_AlwaysAcceptFirst = 1          "回車打開第一個比對項目

let g:LookupFile_AllowNewFiles = 0              "不允許建立不存在的檔案

if filereadable("./filenametags")                "設定tag檔案的名字

    let g:LookupFile_TagExpr = '"./filenametags"'

endif

"nmap <silent> <leader>lk <Plug>LookupFile<cr>   "映射LookupFile為,lk

"nmap <silent> <leader>ll :LUBufs<cr>            "映射LUBufs為,ll

"nmap <silent> <leader>lw :LUWalk<cr>            "映射LUWalk為,lw

"有了上面的定義,當我輸入”,lk”時,就會在tag檔案中查找指定的檔案名;

"當輸入”,ll”時,就會在目前已打開的buffer中查找指定名字的buffer;

"當輸入”,lw”時,就會在指定目錄結構中查找。

"在用lookupfile插件查找檔案時,是區分檔案名的大小寫的,

"如果想進行忽略大小寫的比對,把下面這段代碼加入你的vimrc中,

"就可以每次在查找檔案時都忽略大小寫查找了:

" lookup file with ignore case

function! LookupFile_IgnoreCaseFunc(pattern)

    let _tags = &tags

    try

        let &tags = eval(g:LookupFile_TagExpr)

        let newpattern = '/c' . a:pattern

        let tags = taglist(newpattern)

    catch

        echohl ErrorMsg | echo "Exception: " . v:exception | echohl NONE

        return ""

    finally

        let &tags = _tags

    endtry

    " Show the matches for what is typed so far.

    let files = map(tags, 'v:val["filename"]')

    return files

endfunction

let g:LookupFile_LookupFunc = 'LookupFile_IgnoreCaseFunc'

"====================Lookupfile 相關設定 end========================================

"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

" Add by minico---end

"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

5.參考文檔:

(1)http://blog.csdn.net/wooin/archive/2007/10/31/1858917.aspx

(2)http://blog.csdn.net/easwy/category/234641.aspx

本文來自CSDN部落格,轉載請标明出處:http://blog.csdn.net/minico/archive/2007/12/15/1938050.aspx

繼續閱讀