打印

ubuntu下安装vim+ctags+cscope+taglist读源代码

[复制链接]
245|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
你说说说说|  楼主 | 2018-9-29 12:04 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
vim、ctags、cscope的安装方法很简单,直接sudo apt-get install vim 等

taglist的安装方法,网上有很多说法我照着做都无效,最找到了解决方法:

step1:download the vim taglist plugin



step2:install the taglist vim plugin

$ mkdir ~/.vim # if the directory does not exist already

$cd ~/.vim

$ unzip /usr/src/taglist.zip

Archive:  /usr/src/taglist.zip  

inflating: plugin/taglist.vim

  inflating: doc/taglist.txt



step3:enable the plugin in the ~/.vimrc

$ vim ~/.vimrc         //这一句是新建一个文件,名叫.vimrc

filetype plugin on    //在.vimrc中写入这行字符



step4:如何打开taglist

先使用vim 打开一个源文件,然后输入命令:TlistOpen,然后就出现了:





下面是如何使用taglist(或taglist的特点)

Powerful Features of Taglist Vim Plugin1. Open the Tag List Window in Vim using :TlistOpen# vim mycprogram.c

:TlistOpen

From the vim editor, execute :TlistOpen as shown above, which opens the tag list window with the tags of the current file as shown in the figure below.



Fig: Vim – Source Code Tag/Function List Windows2. Jump to the Function Definition inside a source codeBy clicking on the function name in the left panel, you would be able to go to the definition of the function as shown in the Figure below.



Fig: Jump to a function definition quickly

Apart form jumping to the function names quickly, you can jump to classes, structures, variables, etc., by clicking on the corresponding values from the tag-browser in the left hand side.

3. Jump to the function definition which is in another source fileWhen you are going through a function in a source file and would want to go to the function definition which is in another file, you can do this in two different methods.

Method 1:If you had the ctags generated for that file, when the cursor is in the function call pressing CTRL + ] will take you to the function definition. And automatically the tag list window will show the tags for that newly opened file.

Method  2:Open another file also in the same vim session which will update the tag list window with the information about that file. Search for that function name in the tag list window, and by pressing <CR> on that function name in the tag list window you can go to the function definition.

4. Viewing the prototype/signature of functions or variables.Press ‘space’ in the function name or in the variable name in the tag list window to show the prototype (function signature) of it in the VIM status bar as shown below. In the example below, click on selectDumpableTable function from the Tag-window and press space-bar, which displays the function signature for selectDumptableTable function in the bottom Vim Status bar.



Fig: Display Function signature at the Vim Status Bar5. Viewing the total number of functions or variables in a source code filepress ‘space’ in the tag type in the tag list window, which shows the count of it. In the example below, when the cursor is at ‘function’ press space, which will display the total number of functions in the current source code.



Fig: Display the total number of functions available in the source code

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

355

主题

355

帖子

1

粉丝