用vim阅读内核代码

来源:互联网 发布:linux chkconfig 安装 编辑:程序博客网 时间:2024/04/29 19:53

1. 生成cscope和tags

在内核源码根目录,make cscope tags

2. 安装cscope

3. 安装taglist (http://www.vim.org/scripts/script.php?script_id=273)


使用方法:

cscope:

首先在内核源码根目录打开vim, 输入:cs add cscope.out

查找并打开定义:cs f g do_fork

其他命令,查看帮助:cs help

tags:

在内核源码根目录打开vim

光标在标识符上时,ctrl-] 跳转到标识符定义,ctrl-t返回

taglist: 

编辑~/.vim,输入以下内容

let Tlist_Ctags_Cmd = '/usr/bin/ctags'
let Tlist_Show_One_File = 1
let Tlist_Exit_OnlyWindow = 1
let Tlist_Use_Right_Window = 1
let Tlist_GainFocus_On_ToggleOpen = 1
nnoremap <silent> <F8> :TlistToggle<CR>

然后按F8打开/关闭taglist。在taglist中回车跳转到该标识符,空格查看标识符定义


参考资料:

1. Vim+cscope+ctags+tags阅读源代码

2. vim中taglist的用法