Vim: Close and return to last tab, repeat












1















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



























    1















    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

























      1












      1








      1








      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














      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?







      vim tabs vim-plugins






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 28 '12 at 9:03









      StanAngeloffStanAngeloff

      4516




      4516






















          1 Answer
          1






          active

          oldest

          votes


















          0














          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











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f429618%2fvim-close-and-return-to-last-tab-repeat%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          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
















          0














          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














          0












          0








          0







          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













          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












          share|improve this answer



          share|improve this answer










          answered May 28 '12 at 16:22









          romainlromainl

          18.1k23446




          18.1k23446













          • 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



















          • 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

















          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





          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


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f429618%2fvim-close-and-return-to-last-tab-repeat%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Список кардиналов, возведённых папой римским Каликстом III

          Deduzione

          Mysql.sock missing - “Can't connect to local MySQL server through socket”