Wednesday, November 11, 2009

Reader Question: Tags?

Daniel Näslund writes:

"I use tags a lot. But I'm annoyed by all those open files it leaves
behind. It would be great if the file opened with g] or Ctrl-] would be
closed with Ctrl-T. If the file had been previously opened it would
remain open.

Another thing is a way to close all files except those currently viewed."

I don't use tags too often, so perhaps another reader can answer that question, but if you want to make all buffers except for the current buffer hidden, you can type in the :on ex-command. If you want to hide modified buffers as well, you can do :on!.

If the desired behavior is to actually delete the buffer, and you know it's buffer # or filename, you can do the following:

:bdelete file1 file2 file3

or something like


Lastly, if you want to use a script to accomplish this, there's the BufOnly.vim which provides a single command to unload all buffers except the current one.

No comments: