<script type="text/javascript"> /*<![CDATA[*/ if(top.location != self.location){ top.location = self.location; } var myref = encodeURIComponent("http://hi.baidu.com/hanframe%5Fip/blog/item/4e4da7ef5a7f2c30adafd539%2Ehtml"); /*]]>*/</script>
<script> <!-- function newUserTipShow(f) { if(f=="0"){//close G("newUserTipSwf").style.width="40px"; G("newUserTip").style.width="40px"; G("newUserTipShadow").style.display="none"; }else{//show G("newUserTip").style.width="220px"; G("newUserTipSwf").style.width="220px"; G("newUserTipShadow").style.display="block"; } } function newUserRegLog(){ var now=new Date(); now.setTime(now.getTime()+5*60*1000); document.cookie="BDSP_REGFLAG=1;expires="+now.toGMTString()+";path=/"; } //--> </script> <script type="text/javascript"> function set_cookie_4_bdtip(index/* start from one */, value){ var bdtip = document.cookie.match(/(^| )BDTIP=([^;]*)(;|$)/); if(!bdtip){ bdtip=new Array(index); for(var i=0,n=bdtip.length;i<n;i++) { if(bdtip[i]=="" || bdtip[i]==null) bdtip[i]=0; if(i == index - 1){ bdtip[i] = value; } } }else{ bdtip = bdtip[2].split('-'); if(index > bdtip.length) bdtip.length= index; for(var i = 0, j = bdtip.length; i < j; i ++){ if(bdtip[i]=="" || bdtip[i]==null) bdtip[i]=0; if(i == index - 1){ bdtip[i] = value; } } } bdtip = bdtip.join('-'); document.cookie = "BDTIP=" + bdtip+ ";expires=Wed, 28-Nov-37 01:45:46 GMT;path=/;domain=.baidu.com"; } </script>
本节所用命令的帮助入口:
:help helptags
:help taglist.txt 上篇文章介绍了在VIM中如何使用tag文件,本文主要介绍如何使用taglist插件。 想必用过Source Insight的人都记得这样一个功能:SI能够把当前文件中的宏、全局变量、函数等tag显示在Symbol窗口,用鼠标点上述tag,就跳到该tag定义的位置;可以按字母序、该tag所属的类或scope,以及该tag在文件中出现的位置进行排序;如果切换到另外一个文件,Symbol窗口更新显示这个文件中的tag。 在VIM中的taglist插件所实现的就是上述类似的功能,有些功能比SI弱,有些功能比SI更强。而且,taglist插件仍在不断完善中! 要使用 taglist 插件,必须满足:1. 打开VIM的文件类型自动检测功能; 2. 系统中装了Exuberant ctags工具,并且taglist能够找到此工具(因为taglist需要调用它来生成tag文件); 3. 你的VIM支持system()调用; 在本系列第3篇文章(vimrc初步)中,我们使用了VIM自带的示例vimrc,这个vimrc中已经打开了文件类型检测功能;在上篇文章中,我们也已用到了Exuberant ctags;system()调用在一般的VIM版本都会支持(只有suse Linux发行版中出于安全考虑,关闭了此功能),所以我们已经满足了这三个条件。 现在我们到http://www.vim.org/scripts/script.php?script_id=273下载最新版本的taglist plugin,目前版本是4.3。 下载后,把该文件在~/.vim/目录中解压缩,这会在你的~/.vim/plugin和~/.vim/doc目录中各放入一个文件: plugin/taglist.vim – taglist插件 doc/taglist.txt - taglist帮助文件 注:windows用户需要把这个插件解压在你的$VIM/vimfiles或$HOME/vimfiles目录。
:helptags ~/.vim/doc
生成帮助标签后,你就可以用下面的命令查看taglist的帮助了:
:help taglist.txt
Taglist提供了相当多的功能,我的vimrc中这样配置:
""""""""""""""""""""""""""""""
" Tag list (ctags) """""""""""""""""""""""""""""" if MySys() == "windows" "设定windows系统中ctags程序的位置 let Tlist_Ctags_Cmd = 'ctags' elseif MySys() == "linux" "设定windows系统中ctags程序的位置 let Tlist_Ctags_Cmd = '/usr/bin/ctags' endif let Tlist_Show_One_File = 1 "不同时显示多个文件的tag,只显示当前文件的 let Tlist_Exit_OnlyWindow = 1 |