How to use Ctags to list all the references of a symbol(tag) in vim?
Asked Answered
V

1

19

Can I list all the references of a symbol in vim using Ctags? like the 'Find References' In some GUI IDE.

The Ctag tutorial just tell how to locate the definition of a symbol ,not all the usages.

Vaughnvaught answered 10/6, 2015 at 10:36 Comment(1)
For those looking for a good C# experience in Vim, I highly recommend OmniSharp.Saphead
S
21

The ctags tool only collects and stores the definitions of symbols.

To find all references, you can use the cscope integration into Vim (:help cscope), but note that cscope supports far fewer programming languages than ctags.

Alternatively, a poor man's substitute would be the built-in :grep / :vimgrep commands (with proper patterns). Remember, Vim is a powerful text editor, but no IDE. Either you find and integrate a suitable external tool for this, or switch to a real IDE (like Eclipse, Visual Studio, or IntelliJ IDEA) for such code browsing.

Scalf answered 10/6, 2015 at 10:51 Comment(2)
Worth noting that there are a few projects which extend cscope support to other languages (e.g. github.com/portante/pycscope for python, my own github.com/eapache/starscope for ruby and golang, etc). It still doesn't support nearly as many as ctags, but it's pretty easy to add more to starscope now that the infrastructure is in place.Omega
If you want a full-fledged reference and types and other crazy features, there is a plugin for VIM called YouCompleteMe: github.com/ycm-core/YouCompleteMeSecrete

© 2022 - 2024 — McMap. All rights reserved.