欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

gVIM+ctags+Taglist+winmanager搭建IDE

发布时间:2024/8/23 60 豆豆
生活随笔 收集整理的这篇文章主要介绍了 gVIM+ctags+Taglist+winmanager搭建IDE 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

对于一个初级程序员,Vim和Emacs始终是一个很难跨越的栏,在11年的时候,接触Linux,从而也自然的学习Vim,但是那时候真就是不习惯,Windows的习惯始终无法改过来,随着毕业就不了了之。。。

今年,有从事了单片机开发的工作,至少碰上code了,于是乎想在Vim上动动脑经,学习一下,也参考网上的资料,终于搞了一天,弄出来了,于是就记录一下,是个好习惯,不是吗?

首先,所有的安装包都可以从vim官网下载,安装gvim,我的安装路径是d盘的program files(后来想想还是直接放在d盘好~~),这个时候的vim自带的功能已经很强大了,但是做一个大项目还是有限吃力,所以才会有IDE的出现,方便我们的开发。我这里也是很粗略的,其实还有很大的空间可以提升!~

Ctags是什么?官网的解释是:

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.

他俩的结合就能碰触火花~~哈哈!我之前一直在cfree下编辑代码,然后在别的编译器里编译,给个cfree的截图:

 

 

左边的就是函数(宏定义等)列表,点击一个就会使光标制指定到程序相应的位置去,方便我们查找函数的位置,上面两个就是实现这个功能的。

Taglist文件的压缩包里都有doc和plugin两个文件,对应vim安装目录下的doc和plugin,看出点什么了吧,分别把两个文件里的文件copy到vim安装目录下,这样就安装好了,简单吧~;对于ctags,我起初解压在d盘的program files文件里,结果怎么地都不成功,后来我考虑到program files有个空格,于是我干脆把ctags解压在d盘下,并添加在系统变量里,这才是我的函数列表出来了,狂喜!对于winmanager插件,安装很简单,和taglist一样。接下去的事情就是在编译_vimrc文件。

第二,我把自己的_vimrc的内容显示如下:

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 " 在编辑过程中,在右下角显示光标位置的状态行21 set hlsearch " 高亮显示搜索结果22 set incsearch " 查询时非常方便,如要查找book单词,当输入到/b时,会自动找到23 set ignorecase smartcase24 set foldmethod=syntax25 set foldlevel=100 " Don't autofold anything (but I can still fold manually)26 filetype pluginindenton " 加了这句才可以用智能补全27 set showmatch " 设置匹配模式,类似当输入一个左括号时会匹配相应的那个右括号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 " 自动设置目录为正在编辑的文件所在的目录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名字进行排序65 let Tlist_Show_One_File = 1 "不同时显示多个文件的tag,只显示当前文件的66 let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则退出vim67 let Tlist_Use_Right_Window = 0 "在右侧窗口中显示taglist窗口68 let Tlist_Use_SingleClick = 1 "单击tag就跳转到定义69 let Tlist_GainFocus_On_ToggleOpen = 1 "使用:TlistToggle打开taglist窗口时,输入焦点在taglist窗口中70 nmap <silent> <F9> :TlistToggle<CR> "打开tag窗口,这个是设置快捷键71 72 """"""""""""""73 ""winmanager74 """"""""""""""75 let g:winManagerWindowLayout='FileExplorer|BufExplorer|TagList'76 "nmap <silent> <F10> :WMToggle<cr>77 nmap wm :WMToggle<cr> " 是nomal模式的命令,不是Ex模式的,这个是设置快捷键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!~

转载于:https://www.cnblogs.com/CodeWorkerLiMing/archive/2012/12/22/2829330.html

总结

以上是生活随笔为你收集整理的gVIM+ctags+Taglist+winmanager搭建IDE的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。