vimer linux kernel 爱好者

vim插件-ctags&&cscope

2014-11-29

ctags

原来ctags的功能这么强大,之前自己是蒙着眼使用的啊。

sudo apt-get install ctags

有人说默认有这个插件,确实有,再下一次吧。

$ctags -R *

在你的工作目录中,输入以上命令,$是shell的命令提示符,不是命令的一部分,这一点需要注意,这样就会在当前工作目录下产生ctags的标签文件。

vim -t xx

xx就是你要查找的变量和函数名

It maybe acted on some impact using “SHIFT + K”

:ts

在vim的命令行下输入__:ts__就会列出列表供用户选择满足的变量或者函数(tagslist)。

5. :tp and :tn

display preview tags-file and display next tags-file.

Ctrl + ]

jump to the function or variable where whose were defined.

Ctrl + T or Ctrl + o

Return where jump from where

cscope

Waa…

sudo apt-get install cscope

gen cscope.out file

command:

cscope -Rbqk

-R:表示把所有子目录里的文件也建立索引
-b:仅仅建立符号数据库
-q:生成cscope.in.out和cscope.po.out文件,加快cscope的索引
-k: 在生成索引文件时,不搜索/usr/include目录

vim的normal模式下输入:

:cs add cscope.out

就把索引文件加入到vim中.将以下命令放在.vimrc中,即可省去该命令:

if filereadable("cscope.out")
cs add cscope.out
endif

再试试把下面的内容复制到~/.vimrc里,这样就可以利用相应的快捷键进行不同的查找了. 原文1 原文2 cscope add cscope.out ##4. Commmand & Options After adding the file that is called cscope.out ,we can call cscope find x 简写 cscope f x

c:Find functions calling this function
d:Find functions called by this function
e:Find this egrep pattern
f:Find this file
g:Find this definition
i:Find files #including this file
s:Find this C symbol
t:Find assignments to

#taglist 将这三个工具用起来了,然后在命令窗口中键入:

:TlistToggle

在关闭与打开之间转换.

我的vimrc中定义了下面的映射,使用“,tl”键就可以打开/关闭taglist窗口:

map tl :TlistToogle


下一篇 什么是爱情

Comments

Content