gVIM+ctags+Taglist+winmanager搭建IDE
對(duì)于一個(gè)初級(jí)程序員,Vim和Emacs始終是一個(gè)很難跨越的欄,在11年的時(shí)候,接觸Linux,從而也自然的學(xué)習(xí)Vim,但是那時(shí)候真就是不習(xí)慣,Windows的習(xí)慣始終無法改過來,隨著畢業(yè)就不了了之。。。
今年,有從事了單片機(jī)開發(fā)的工作,至少碰上code了,于是乎想在Vim上動(dòng)動(dòng)腦經(jīng),學(xué)習(xí)一下,也參考網(wǎng)上的資料,終于搞了一天,弄出來了,于是就記錄一下,是個(gè)好習(xí)慣,不是嗎?
首先,所有的安裝包都可以從vim官網(wǎng)下載,安裝gvim,我的安裝路徑是d盤的program files(后來想想還是直接放在d盤好~~),這個(gè)時(shí)候的vim自帶的功能已經(jīng)很強(qiáng)大了,但是做一個(gè)大項(xiàng)目還是有限吃力,所以才會(huì)有IDE的出現(xiàn),方便我們的開發(fā)。我這里也是很粗略的,其實(shí)還有很大的空間可以提升!~
Ctags是什么?官網(wǎng)的解釋是:
Ctags?generates an index (or?tag) file of language objects found in source files that allows these items to be quickly and easily located by a text editor or other utility. A?tag?signifies a language object for which an index entry is available (or, alternatively, the index entry created for that object).
Taglist呢??
The "Tag List" plugin is a source code browser for the Vim editor. It provides an overview of the structure of source code files and allows you to efficiently browse through source code files in different programming languages. It is the?top-rated and most-downloaded plugin?for the Vim editor.
The taglist plugin groups and displays the functions, classes, structures, enumerations, macro definitions and other parts of a source code file in a Vim window. The taglist plugin will automatically highlight the current tag. You can jump to the definition of a tag by selecting the tag name from the taglist window. For a list of features supported by the taglist plugin, visit the?features?page.
他倆的結(jié)合就能碰觸火花~~哈哈!我之前一直在cfree下編輯代碼,然后在別的編譯器里編譯,給個(gè)cfree的截圖:
?
?
左邊的就是函數(shù)(宏定義等)列表,點(diǎn)擊一個(gè)就會(huì)使光標(biāo)制指定到程序相應(yīng)的位置去,方便我們查找函數(shù)的位置,上面兩個(gè)就是實(shí)現(xiàn)這個(gè)功能的。
Taglist文件的壓縮包里都有doc和plugin兩個(gè)文件,對(duì)應(yīng)vim安裝目錄下的doc和plugin,看出點(diǎn)什么了吧,分別把兩個(gè)文件里的文件copy到vim安裝目錄下,這樣就安裝好了,簡(jiǎn)單吧~;對(duì)于ctags,我起初解壓在d盤的program files文件里,結(jié)果怎么地都不成功,后來我考慮到program files有個(gè)空格,于是我干脆把ctags解壓在d盤下,并添加在系統(tǒng)變量里,這才是我的函數(shù)列表出來了,狂喜!對(duì)于winmanager插件,安裝很簡(jiǎn)單,和taglist一樣。接下去的事情就是在編譯_vimrc文件。
第二,我把自己的_vimrc的內(nèi)容顯示如下:
1 set nocompatible2 source $VIMRUNTIME/vimrc_example.vim3 source $VIMRUNTIME/mswin.vim4 behave mswin5 syntax enable6 syntax on 7 set guifont=Courier\ New:h138 set nu!9 set ts=410 set sw=411 set smartindent12 set laststatus=213 set cursorline14 set autoindent15 set cindent16 set linebreak17 set hidden18 set gdefault19 set scrolloff=520 set ruler " 在編輯過程中,在右下角顯示光標(biāo)位置的狀態(tài)行21 set hlsearch " 高亮顯示搜索結(jié)果22 set incsearch " 查詢時(shí)非常方便,如要查找book單詞,當(dāng)輸入到/b時(shí),會(huì)自動(dòng)找到23 set ignorecase smartcase24 set foldmethod=syntax25 set foldlevel=100 " Don't autofold anything (but I can still fold manually)26 filetype pluginindenton " 加了這句才可以用智能補(bǔ)全27 set showmatch " 設(shè)置匹配模式,類似當(dāng)輸入一個(gè)左括號(hào)時(shí)會(huì)匹配相應(yīng)的那個(gè)右括號(hào)28 set noexpandtab29 set tabstop=430 set nobk31 32 33 "--------------------------------------------------------------------------------34 " 代碼折疊35 "--------------------------------------------------------------------------------36 set foldmarker={,}37 "set foldmethod=marker38 set foldmethod=syntax39 set foldlevel=100 " Don't autofold anything (but I can still fold manually)40 "set foldopen-=search " don't open folds when you search into them41 "set foldopen-=undo " don't open folds when you undo stuff42 "set foldcolumn=443 44 45 "Taglist------------------------------------------------46 "==================================================47 let Tlist_Show_Menu=148 let Tlist_Ctags_Cmd='D:\ctags58\ctags.exe'”這句話可有可無,但我還是加了,以防萬一49 let Tlist_Auto_Open=150 let Tlist_File_Fold_Auto_Close=051 let Tlist_Compact_Format=152 let Tlist_Enable_Fold_Column=153 let Tlist_Sort_Type="order"54 set tags=tags;55 set autochdir " 自動(dòng)設(shè)置目錄為正在編輯的文件所在的目錄56 57 filetype plugin on58 59 " taglist configuration vimrc file.60 "61 " Maintainer: Bruce Ouyang <bruce.oy@gmail.com>62 "63 let Tlist_Display_Prototype = 164 let Tlist_Sort_Type = "order" "使taglist以tag名字進(jìn)行排序65 let Tlist_Show_One_File = 1 "不同時(shí)顯示多個(gè)文件的tag,只顯示當(dāng)前文件的66 let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一個(gè)窗口,則退出vim67 let Tlist_Use_Right_Window = 0 "在右側(cè)窗口中顯示taglist窗口68 let Tlist_Use_SingleClick = 1 "單擊tag就跳轉(zhuǎn)到定義69 let Tlist_GainFocus_On_ToggleOpen = 1 "使用:TlistToggle打開taglist窗口時(shí),輸入焦點(diǎn)在taglist窗口中70 nmap <silent> <F9> :TlistToggle<CR> "打開tag窗口,這個(gè)是設(shè)置快捷鍵71 72 """"""""""""""73 ""winmanager74 """"""""""""""75 let g:winManagerWindowLayout='FileExplorer|BufExplorer|TagList'76 "nmap <silent> <F10> :WMToggle<cr>77 nmap wm :WMToggle<cr> " 是nomal模式的命令,不是Ex模式的,這個(gè)是設(shè)置快捷鍵78 79 80 """"""""""""""""""""""""""""""""""""""""""""""81 ""omni completion 82 """"""""""""""""""""""""""""""""""""""""""""""83 set nocp84 set ofu=syntaxcomplete#Complete85 86 set diffexpr=MyDiff()87 function MyDiff()88 let opt = '-a --binary '89 if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif90 if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif91 let arg1 = v:fname_in92 if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif93 let arg2 = v:fname_new94 if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif95 let arg3 = v:fname_out96 if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif97 let eq = ''98 if $VIMRUNTIME =~ ' '99 if &sh =~ '\<cmd' 100 let cmd = '""' . $VIMRUNTIME . '\diff"' 101 let eq = '"' 102 else 103 let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"' 104 endif 105 else 106 let cmd = $VIMRUNTIME . '\diff' 107 endif 108 silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq 109 endfunction效果圖:
?按下wm,如下:
哈哈!I get it!~
轉(zhuǎn)載于:https://www.cnblogs.com/CodeWorkerLiMing/archive/2012/12/22/2829330.html
總結(jié)
以上是生活随笔為你收集整理的gVIM+ctags+Taglist+winmanager搭建IDE的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 论文(一)
- 下一篇: 博客园——记录我的开始