Table of Contents
vim gtags
gtags.files
find . -name '*.cc' -type f > cscope.files find . -name '*.[ch]' -type f >> cscope.files ln -s scope.files gtags.files # for vim plugin
當gtags.files檔案存在的時候,gtags只對該檔案中列出檔案索引。
find . -type f -print >gtags.files
If ´gtags.files´ exists in the current directory or a file is specified by the -f option, target files are limited by it. - https://www.gsp.com/cgi-bin/man.cgi?section=1&topic=gtags
touch .root
gtags vim setting
set tags=./.tags;,.tags let g:gutentags_define_advanced_commands = 1 set statusline+=%{gutentags#statusline()} Plugin 'skywind3000/vim-preview' let g:gutentags_ctags_tagfile = '.tags' Plugin 'ludovicchabant/vim-gutentags' Plugin 'skywind3000/gutentags_plus' " enable gtags module "let g:gutentags_modules = ['ctags', 'gtags_cscope'] let g:gutentags_modules = ['gtags_cscope'] " config project root markers. let g:gutentags_project_root = ['.root'] " generate datebases in my cache directory, prevent gtags files polluting my " project "let g:gutentags_cache_dir = expand('~/.cache/tags') let g:gutentags_cache_dir = expand('/p/.cache/tags') " forbid gutentags adding gtags databases let g:gutentags_auto_add_gtags_cscope = 0 let g:gutentags_auto_add_gtags_cscope = 0 autocmd FileType qf nnoremap <silent><buffer> p :PreviewQuickfix<cr> autocmd FileType qf nnoremap <silent><buffer> P :PreviewClose<cr>
referece
preview https://medium.com/usevim/vim-101-preview-window-40039d37f4ec
Vim 8 中 C/C++ 符号索引:GTags 篇 https://zhuanlan.zhihu.com/p/36279445
安装最新版本 gtags,目前版本是 6.6.2
如何在 Linux 下利用 Vim 搭建 C/C++ 开发环境? https://www.zhihu.com/question/47691414/answer/373700711
plus https://github.com/skywind3000/gutentags_plus https://github.com/jsfaint/gen_tags.vim
Configuration mkdir .root touch .root
:GscopeFind {querytype} {name} You may be interested in the vim-preview plugin, it can preview results from quickfix window when you press p.
https://github.com/skywind3000/vim-preview
Plug 'skywind3000/vim-preview'
issue
vim vim tag plugin https://del.dog/atakomociw.makefile
Vim 8 中 C/C++ 符号索引:GTags 篇 https://zhuanlan.zhihu.com/p/36279445
如何在 Linux 下利用 Vim 搭建 C/C++ 开发环境? https://www.zhihu.com/question/47691414/answer/373700711
Gutentags https://bolt80.com/gutentags/
https://github.com/ludovicchabant/vim-gutentags/issues/169 https://github.com/ludovicchabant/vim-gutentags/issues/196
Can I manually generate tags files? #187 https://github.com/ludovicchabant/vim-gutentags/issues/187
temporary tags file into cache dir #9 https://github.com/ludovicchabant/vim-gutentags/issues/9
creating a .gutctags file at the root of your project https://github.com/ludovicchabant/vim-gutentags/issues/33
misc
g:gutentags_gtags_options_file The name of a file that will be looked for in a project root directory. The file is expected to contain `gtags` options (one per line). Defaults to `".gutgtags"`.
https://medium.com/heynote/use-gtags-gnu-global-with-vim-replace-ctags-and-cscope-15ae03f272e3
Plugin ‘aceofall/gtags.vim’ set cscopetag
https://blog.zhustec.me/posts/use-gtags-for-source-code-navigation-in-vim
1 Plugin 'aceofall/gtags.vim' " cscope 2 set cscopetag " 使用 cscope 作为 tags 命令 3 set cscopeprg='gtags-cscope' " 使用 gtags-cscope 代替 cscope 4
vim ctags cscope cscope.files
ctags config
Way 1
ctags usage $ ctags -R * cscope usage $ cscope -Rbqk
ctag -R 產生當前項目內所有源文件對應的 tag 標籤文件
Ctrl + ] go to def
ctags -R –c++-kinds=+p+l+x+c+d+e+f+g+m+n+s+t+u+v –fields=+liaS –extra=+q
Vim自动生成tags插件vim-gutentags安装和自动跳转方法-Vim插件(10) https://vim.ink/vim-gutentags.html
Way 2 cscope.files
find . -name '*.cc' -type f > cscope.files find . -name '*.[ch]' -type f >> cscope.files cscope -b -q -k
cscope -d
Ref
https://github.com/ludovicchabant/vim-gutentags https://github.com/skywind3000/gutentags_plus see this one https://github.com/skywind3000/gutentags_plus it has example config
如何在 Linux 下利用 Vim 搭建 C/C++ 开发环境? https://www.zhihu.com/question/47691414/answer/373700711
vim ctags setting
set tags=./.tags;,.tags
把 tag 文件的名字從“tags” 換成了“.tags”,前面多加了一個點, 這樣即便放到項目中也不容易污染當前項目的文件, 刪除時也好刪除, gitignore 也好寫, 默認忽略點開頭的文件名即可。 前半部分“./.tags; ”代表在文件的所在目錄下(不是“:pwd”返回的Vim 當前目錄)查找名字為“.tags”的符號文件, 後面一個分號代表查找不到的話向上遞歸到父目錄, 直到找到.tags 文件或者遞歸到了根目錄還沒找到, 這樣對於復雜工程很友好, 源代碼都是分佈在不同子目錄中, 而只需要在項目頂層目錄放一個.tags文件即可; 逗號分隔的後半部分.tags 是指同時在Vim 的當前目錄(“:pwd”命令返回的目錄,可以用:cd ..命令改變)下面查找.tags 文件。
不要使用老旧的 Exuberant Ctags,这货停止更新快十年了,请使用最新的 Universal CTags 代替之
Vim自动生成tags插件vim-gutentag使用方法 https://zhuanlan.zhihu.com/p/43671939
preview window
See https://medium.com/usevim/vim-101-preview-window-40039d37f4ec
:ptag CTRL-W } CTRL-W z close preview
Tip
https://blog.csdn.net/dengxiayehu/article/details/6330200
建議用法 cscopetag
假如’cscopetag’被设置, 然后诸如”:tag”和ctrl+]和”vim -t”等命令会始终使用|:cstag|而不是默认的:tag行为。 通过设置’cst’, 你将始终同时查找cscope数据库和tags文件。默认情况是关闭的,例如:
:set cst :set nocst
http://www.skywind.me/blog/archives/2084
少用 CTRL-] 直接在当前窗口里跳转到定义, 多使用 CTRL-W ] 用新窗口打开并查看光标下符号的定义, 或者 CTRL-W } 使用 preview 窗口预览光标下符号的定义。
global gtags 介绍一下gnu global,比cscope更方便更快速的索引工具 http://forum.ubuntu.org.cn/viewtopic.php?t=343460
在 Vim 中使用 Gtags 进行代码导航 https://blog.zhustec.me/posts/use-gtags-for-source-code-navigation-in-vim
1 " cscope 2 set cscopetag " 使用 cscope 作为 tags 命令 3 set cscopeprg='gtags-cscope' " 使用 gtags-cscope 代替 cscope
https://medium.com/heynote/use-gtags-gnu-global-with-vim-replace-ctags-and-cscope-15ae03f272e3 Use Gtags/Gnu Global with Vim, replace ctags and cscope
set cscopetag set cscopeprg=’gtags-cscope’
gtags CLI
gtags global -u gtags-cscope -d
-d Do not update the cross-reference.
Ctrl-D quit
global -f xxxx.c | fzf
gtags htags --suggest # make hypertext(HTML/)
https://forum.ubuntu.org.cn/viewtopic.php?t=343460
htags htags-server
gtags htags --suggest htags -F -f htags-server