Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I find myself in this situation very often:

  1. Open gVim with NERDTree from current working directory.
  2. Open a file from NERDTree using <S-T> so it grabs a new tab.
  3. :tabprevious to return to NERDTree.
  4. Explore directories and open a second file using <S-T>.
  5. Close the second file, :q or ZZ.

What I would have expected to happen after 5. is to return to NERDTree, but Vim always collapses the tab and opens the one to the right. This is rarely what I intended to do and would much rather have Vim keep a list of all tabs I have cycled through. So, as I close one, it pops it off the stack and focuses the next.

This can be seen in other editors, mostly IDEs, like Komodo Edit for example.

Is there a plug-in which would do this for Vim?

share|improve this question
add comment

1 Answer

To go to the first tab (presumably the one with NERDTree open), do :tabfirst. Vim doesn't keep a list of tabs ordered by "most recently accessed" and :tabprevious/:tabnext only deal with the tabs on the left/right.

The default action for T is precisely to open the selected file in a new tab and come back to the tab where NERDTree is located. So I'm not sure why you have to do :tabprevious after T.

A common way to use NERDTree is to simply open it on the spot, when you need it, and set it to close itself upon opening a file. I don't remember the name of the option but a quick :help nerdtree would be enough.

Also I'm afraid you are making a mistake here: you are using Vim's "tabs" as if they where the same as the tabs found everywhere else. This is a bad idea because they are not designed that way at all. Instead, read up on windows and buffers.

share|improve this answer
    
Thanks for this comment. I am fairly advanced with Vim, which should have been mentioned in the original post. If no one has indeed came across this sort of behaviour (provided by a plug-in), it would make for a good weekend project. –  StanAngeloff May 29 '12 at 4:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.