Ayush
Ayush

Reputation: 342

Unable to go to tags while editing a file in vim

I'm editing a source file in Vim, and in the middle of it I want to search for a tag (to understand some variable/class/method etc.), and I click Ctrl+] to look for the tag, and if the tag is supposed to be in a different file, it doesn't allow me to move away from the current file because it is being edited - it displays the usual Vim error - "E37: No write since last change (add ! to override)"

The workaround I have is to save the file first and re-open it and then look for the tag.

Is there a way to search the tags without having to save and reopen the file.

Upvotes: 0

Views: 256

Answers (1)

romainl
romainl

Reputation: 196596

You can put the following line in your vimrc to allow Vim to edit another buffer without having to write the current one:

set hidden

See :help 'hidden'.

If you don't want to set that option, the alternative would be to use <C-w>], which opens the tag in a new window. See :help ctrl-w_].

Note that, as pointed out in a comment, you don't have to write and quit the current buffer in order to jump to a tag: writing it is enough.

Upvotes: 2

Related Questions