Index

Table of contents

ctags

install ctags
sudo apt install -y ctags
create a tag file for the specified files
ctags [file]...
create the tag file ./ctags by recursive indexing directories
ctags -R [directory]...
ctags --recurse [directory]...
append to ctags file, instead of overwrite
--append
specify filename
-f [file]
print tag file to system output
-f -
exclude files / directories
--exclude=[pattern]
list kind of tags available per language
ctags −−list−kinds
list kind of tags available for a specific language
ctags --list-kinds=java

vim

show current tags lookup path
:set tags?
tell vim where to find tag files
:set tags=./tags,./../tags,./*/tags
recursive directory search for tag files
:set tags=~/proj/**/tags
jump to tag
:tag? [tag]
:stag? [tag]    # split
show next matching tag (e.g. java.util.List, java.awt.List)
:tnext
:tn
show previous matching tag
:tprevious
:tp
:tN
show all matching tags
:tselect  [tag]
:ts       [tag]
:stselect [tag]    # split
:sts      [tag]    # split
:tjump    [tag]    # if only one match -> jump there
:tj       [tag]    # if only one match -> jump there
regex search for tag
:tag     /[regex]
:tselect /[regex]
case sensitive regex
:tag     /[regex]\c
:tselect /[regex]\c
lookup tag for word under cursor
ctrl-]          # open first match
ctrl-w ]        # split (type number first to set height)
g]              # tag select
g ctrl-]        # tag select, or jump if only one match
show tag stack
:tags
previous tag (stack pop)
ctrl-t
:pop?
newer tag (reverse of pop)
:tag
go back [n] tags
[n] ctrl-t
:[n]pop
show function definition in preview window
:ptag [tag]
ctrl-w }
jump to tag by index
:[n]?tr(ewind)?
:[n]?tf(irst)?
:tl(ast)?
replace tag stack with matches
ltag [name]

preview window

preview match from current file (even if not in tags file)
:psearch [tag]
close preview window
:pclose
preview alternatives to tag commands
ptselect   -> tselect
pts        -> tselect
ptjump     -> tjump
ptj        -> tjump
ptnext     -> ...
ptn        -> ...
ptprevious
ptp
ptNext
ptN
ptrewind
ptr
ptfirst
ptf
ptlast
ptl

documentation

https://vimhelp.org/tagsrch.txt.html#tagsrch.txt
http://ctags.sourceforge.net/ctags.html#HOW%20TO%20USE%20WITH%20VI