1. 安装ctags
[email protected]:~# apt-get install ctags
2. 设置内核目录的ctags
[email protected]:/study/linux-git/linux-git/linux-3.18.3# ls
arch Documentation include kernel net security
block drivers init lib README sound
COPYING firmware ipc MAINTAINERS REPORTING-BUGS tools
CREDITS fs Kbuild Makefile samples usr
crypto git-test.txt Kconfig mm scripts virt
[email protected]:/study/linux-git/linux-git/linux-3.18.3# pwd
/study/linux-git/linux-git/linux-3.18.3
[email protected]:/study/linux-git/linux-git/linux-3.18.3# ctags -R
3. 此时在 目录 下生成一个tags文件
[email protected]:/study/linux-git/linux-git/linux-3.18.3# ls
arch Documentation include kernel net security virt
block drivers init lib README sound
COPYING firmware ipc MAINTAINERS REPORTING-BUGS tags
CREDITS fs Kbuild Makefile samples tools
crypto git-test.txt Kconfig mm scripts usr
[email protected]:/study/linux-git/linux-git/linux-3.18.3#
在vim中执行如下命令使用tags:
set tags=/study/linux-git/linux-git/linux-3.18.3/tags
或者在.vimrc中添加本vim命令,则可以通过ctrl + ] 和ctrl+T跳来跳去了
4. 使用ctags功能
ctrl + ] 跳到定义处
ctrl + T 跳回远处