I'm using Ctrl-] in Vim to navigate using Ctags. How do I navigate to alternate file if there are multiple matches?
Ex. something.publish
in a codebase containing multiple occurrences of publish
:
class Foo def publish end end class Bar def publish end end
Vim's built-in code navigation functionality using ctags is fantastically useful. Properly configured, it can allow you to jump from file to file in a project with one or two keypresses. Position the cursor over an object or function name, press C-] and Vim takes you directly to its definition; C-o takes you back.
You can position the cursor over the tag and press g Ctrl-]. You can visually select a text and press g Ctrl-] to jump or list the matching tags. You can use the 'stjump' ex command. This will open the matching or selected tag from the tag list in a new window.
Select tag from tag list. You can select a particular tag from the tag list after opening the file in the vim editor by using ctags command. Open any source code in vim editor and type ':tselect' to find out the list of tag list of current source code. Here, the same file, abs_num.py is used to check this command.
Use g]
instead of C-]
to get the list of all matches.
You might want to read :help g]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With