Loading ...
Sorry, an error occurred while loading the content.

Tab Order

Expand Messages
  • Paul
    When I close a tab, I d like vim to take me back to the last tab that I was in, rather than the next in line. For example: I have several tabs open: [1] [2]
    Message 1 of 15 , May 14, 2012
    • 0 Attachment
      When I close a tab, I'd like vim to take me back to the last tab that I was in, rather than the next in line. For example:

      I have several tabs open:

      [1] [2] [3]

      I'm in tab [1]. I open a new tab, [a], which opens after tab [1]:

      [1] [a] [2] [3]

      I'm now in my new tab, [a]. I close it:

      [1] [2] [3]

      I'm now in tab [2], but I wanted to be put in tab [1].

      Is it possible?

      --

      .

      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • Ben Fritz
      ... It is certainly possible if you make your own command/mapping to close tabs rather than using the built-in ways. Make a TabEnter and/or TabLeave autocmd to
      Message 2 of 15 , May 14, 2012
      • 0 Attachment
        On Monday, May 14, 2012 7:01:17 AM UTC-5, Jan wrote:
        > When I close a tab, I'd like vim to take me back to the last tab that I was in, rather than the next in line. For example:
        >
        > I have several tabs open:
        >
        > [1] [2] [3]
        >
        > I'm in tab [1]. I open a new tab, [a], which opens after tab [1]:
        >
        > [1] [a] [2] [3]
        >
        > I'm now in my new tab, [a]. I close it:
        >
        > [1] [2] [3]
        >
        > I'm now in tab [2], but I wanted to be put in tab [1].
        >
        > Is it possible?
        >

        It is certainly possible if you make your own command/mapping to close tabs rather than using the built-in ways.

        Make a TabEnter and/or TabLeave autocmd to update a global variable with the tab number of the most recent tab, or a list of most recently visited tabs in order. Then your custom command can simply close the current tab, adjust the tab numbers of the remaining tabs accordingly, then switch to the most recent tab. Be careful not to fire off your autocmd while closing the tab. You can use the 'eventignore' option for this.

        The tabpagenr() function should be useful for this.

        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • Bert Swart
        ... I have this in my vimrc: nnoremap td :tabclose gT HTH, Bert ... -- You received this message from the vim_use maillist. Do not top-post! Type
        Message 3 of 15 , May 15, 2012
        • 0 Attachment
          On Mon, May 14, 2012 at 01:01:17PM +0100, Paul wrote:
          > When I close a tab, I'd like vim to take me back to the last tab that I was in, rather than the next in line. For example:
          >
          > I have several tabs open:
          >
          > [1] [2] [3]
          >
          > I'm in tab [1]. I open a new tab, [a], which opens after tab [1]:
          >
          > [1] [a] [2] [3]
          >
          > I'm now in my new tab, [a]. I close it:
          >
          > [1] [2] [3]
          >
          > I'm now in tab [2], but I wanted to be put in tab [1].
          >
          > Is it possible?

          I have this in my vimrc:
          nnoremap <leader>td :tabclose<cr>gT

          HTH,
          Bert
          >
          > --
          >
          > .
          >
          > --
          > You received this message from the "vim_use" maillist.
          > Do not top-post! Type your reply below the text you are replying to.
          > For more information, visit http://www.vim.org/maillist.php

          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        • Ben Fritz
          ... I read this as wanting to jump back to the most recent tab, no matter where it is. E.g., you re in tab 1, open tab a as shown, go to tab 3, then back to
          Message 4 of 15 , May 15, 2012
          • 0 Attachment
            On Monday, May 14, 2012 7:01:17 AM UTC-5, Jan wrote:
            > When I close a tab, I'd like vim to take me back to the last tab that I was in, rather than the next in line. For example:
            >
            > I have several tabs open:
            >
            > [1] [2] [3]
            >
            > I'm in tab [1]. I open a new tab, [a], which opens after tab [1]:
            >
            > [1] [a] [2] [3]
            >
            > I'm now in my new tab, [a]. I close it:
            >
            > [1] [2] [3]
            >
            > I'm now in tab [2], but I wanted to be put in tab [1].
            >
            > Is it possible?
            >

            I read this as wanting to jump back to the most recent tab, no matter where it is. E.g., you're in tab 1, open tab a as shown, go to tab 3, then back to tab a, then close tab a, you wanted to be in tab 3. Is this correct? If not, and all you want is to go to the left tab instead of the right tab, then we have a tip for that:

            http://vim.wikia.com/wiki/Have_focus_on_left_tab_after_tabclose

            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php
          • Paul
            ... That s correct. Most of the suggested solutions so far would have me retrain myself in the way that I close tabs (ie. type something other than :q), which
            Message 5 of 15 , May 19, 2012
            • 0 Attachment
              On Tuesday, 15 May, 2012 at 16:44:12 BST, Ben Fritz wrote:
              >I read this as wanting to jump back to the most recent tab, no matter where it is. E.g., you're in tab 1, open tab a as shown, go to tab 3, then back to tab a, then close tab a, you wanted to be in tab 3. Is this correct?

              That's correct. Most of the suggested solutions so far would have me retrain myself in the way that I close tabs (ie. type something other than :q), which I'm not willing to do. I thought that there might be a setting for this, but I suppose I'll have to create a function like you suggested in your other post.

              --

              .

              --
              You received this message from the "vim_use" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php
            • Ben Fritz
              ... Well...if you successfully create your command, you can make it invoke with :q, as discussed here:
              Message 6 of 15 , May 20, 2012
              • 0 Attachment
                On Saturday, May 19, 2012 8:40:10 AM UTC-5, Jan wrote:
                > On Tuesday, 15 May, 2012 at 16:44:12 BST, Ben Fritz wrote:
                > >I read this as wanting to jump back to the most recent tab, no matter where it is. E.g., you're in tab 1, open tab a as shown, go to tab 3, then back to tab a, then close tab a, you wanted to be in tab 3. Is this correct?
                >
                > That's correct. Most of the suggested solutions so far would have me retrain myself in the way that I close tabs (ie. type something other than :q), which I'm not willing to do. I thought that there might be a setting for this, but I suppose I'll have to create a function like you suggested in your other post.
                >

                Well...if you successfully create your command, you can make it invoke with :q, as discussed here:

                http://vim.wikia.com/wiki/Replace_a_builtin_command_using_cabbrev

                --
                You received this message from the "vim_use" maillist.
                Do not top-post! Type your reply below the text you are replying to.
                For more information, visit http://www.vim.org/maillist.php
              • Scott
                Hi Jan, I d like to be able to make Vim focus the left tab too (after closing a tab). Did you find a way to do it without having to use a new command? Scott.
                Message 7 of 15 , May 31, 2012
                • 0 Attachment
                  Hi Jan,

                  I'd like to be able to make Vim focus the left tab too (after closing a tab). Did you find a way to do it without having to use a new command?

                  Scott. :)

                  On Saturday, May 19, 2012 11:40:10 PM UTC+10, Jan wrote:
                  > On Tuesday, 15 May, 2012 at 16:44:12 BST, Ben Fritz wrote:
                  > >I read this as wanting to jump back to the most recent tab, no matter where it is. E.g., you're in tab 1, open tab a as shown, go to tab 3, then back to tab a, then close tab a, you wanted to be in tab 3. Is this correct?
                  >
                  > That's correct. Most of the suggested solutions so far would have me retrain myself in the way that I close tabs (ie. type something other than :q), which I'm not willing to do. I thought that there might be a setting for this, but I suppose I'll have to create a function like you suggested in your other post.
                  >
                  > --
                  >
                  > .

                  --
                  You received this message from the "vim_use" maillist.
                  Do not top-post! Type your reply below the text you are replying to.
                  For more information, visit http://www.vim.org/maillist.php
                • Paul
                  ... Hi Mary, Haven t have the time yet :/ -- . -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you
                  Message 8 of 15 , Jun 1, 2012
                  • 0 Attachment
                    On Friday, 01 June, 2012 at 04:37:50 BST, Scott wrote:
                    >Hi Jan,
                    >
                    >I'd like to be able to make Vim focus the left tab too (after closing a tab). Did you find a way to do it without having to use a new command?

                    Hi Mary,

                    Haven't have the time yet :/

                    --

                    .

                    --
                    You received this message from the "vim_use" maillist.
                    Do not top-post! Type your reply below the text you are replying to.
                    For more information, visit http://www.vim.org/maillist.php
                  • Ben Fritz
                    ... If all you want is the left tab, the link I posted should do that. You can t do it without creating a new command, though.
                    Message 9 of 15 , Jun 1, 2012
                    • 0 Attachment
                      On Thursday, May 31, 2012 10:37:50 PM UTC-5, Scott wrote:
                      > Hi Jan,
                      >
                      > I'd like to be able to make Vim focus the left tab too (after closing a tab). Did you find a way to do it without having to use a new command?
                      >

                      If all you want is the left tab, the link I posted should do that. You can't do it without creating a new command, though.

                      http://vim.wikia.com/wiki/Have_focus_on_left_tab_after_tabclose

                      But, you might be able to hack a TabLeave/TabEnter autocmd to do things automatically, or you can use abbreviations to automatically trigger your new command, as mentioned.

                      http://vim.wikia.com/wiki/Replace_a_builtin_command_using_cabbrev

                      --
                      You received this message from the "vim_use" maillist.
                      Do not top-post! Type your reply below the text you are replying to.
                      For more information, visit http://www.vim.org/maillist.php
                    • Karthick Gururaj
                      ... I tried doing this and ran into an issue.. The script: au TabEnter * call TabEnterFunc() au TabLeave * call TabLeaveFunc() func! TabEnterFunc() echo
                      Message 10 of 15 , Jun 7, 2012
                      • 0 Attachment
                        On Fri, Jun 1, 2012 at 8:02 PM, Ben Fritz <fritzophrenic@...> wrote:
                        > On Thursday, May 31, 2012 10:37:50 PM UTC-5, Scott wrote:
                        >> Hi Jan,
                        >>
                        >> I'd like to be able to make Vim focus the left tab too (after closing a tab). Did you find a way to do it without having to use a new command?
                        >>
                        >
                        > If all you want is the left tab, the link I posted should do that. You can't do it without creating a new command, though.
                        >
                        > http://vim.wikia.com/wiki/Have_focus_on_left_tab_after_tabclose
                        >
                        > But, you might be able to hack a TabLeave/TabEnter autocmd to do things automatically, or you can use abbreviations to automatically trigger your new command, as mentioned.
                        >
                        > http://vim.wikia.com/wiki/Replace_a_builtin_command_using_cabbrev
                        I tried doing this and ran into an issue..

                        The script:
                        au TabEnter * call TabEnterFunc()
                        au TabLeave * call TabLeaveFunc()

                        func! TabEnterFunc()
                        echo 'Enter: ' . tabpagenr("$")
                        sleep 1
                        endfunc

                        func! TabLeaveFunc()
                        echo 'Leave: ' . tabpagenr("$")
                        sleep 1
                        endfunction

                        If a new tab is created with:
                        :tabnew
                        the prints are,
                        Leave: 1
                        Enter: 2
                        (i.e, the number of tabs on TabEnter is one more than when TabLeave
                        triggered). This is good.

                        But when we quit a tab with :q, we get,
                        Leave: 2
                        Enter: 2

                        Shouldn't the number of buffers as returned by tabpagenr("$") be
                        up-to-date by the time TabEnter gets triggered?

                        :version
                        VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Aug 9 2008 18:46:22)
                        MS-Windows 32-bit GUI version with OLE support
                        Compiled by Bram@KIBAALE
                        Big version with GUI. Features included (+) or not (-):
                        +arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset
                        +cindent +clientserver +clipboard +cmdline_compl +cmdline_hist
                        +cmdline_info +comments
                        +cryptv +cscope +cursorshape +dialog_con_gui +diff +digraphs -dnd
                        -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path
                        +find_in_path
                        +float +folding -footer +gettext/dyn -hangul_input +iconv/dyn
                        +insert_expand +jumplist +keymap +langmap +libcall +linebreak
                        +lispindent +listcmds +localmap
                        +menu +mksession +modify_fname +mouse +mouseshape +multi_byte_ime/dyn
                        +multi_lang -mzscheme +netbeans_intg +ole -osfiletype +path_extra
                        +perl/dyn
                        -postscript +printer -profile +python/dyn +quickfix +reltime
                        +rightleft +ruby/dyn +scrollbind +signs +smartindent -sniff
                        +statusline -sun_workshop +syntax
                        +tag_binary +tag_old_static -tag_any_white +tcl/dyn -tgetent
                        -termresponse +textobjects +title +toolbar +user_commands +vertsplit
                        +virtualedit +visual
                        +visualextra +viminfo +vreplace +wildignore +wildmenu +windows
                        +writebackup -xfontset -xim -xterm_save +xpm_w32
                        system vimrc file: "$VIM\vimrc"
                        user vimrc file: "$HOME\_vimrc"
                        2nd user vimrc file: "$VIM\_vimrc"
                        user exrc file: "$HOME\_exrc"
                        2nd user exrc file: "$VIM\_exrc"
                        system gvimrc file: "$VIM\gvimrc"
                        user gvimrc file: "$HOME\_gvimrc"
                        2nd user gvimrc file: "$VIM\_gvimrc"
                        system menu file: "$VIMRUNTIME\menu.vim"
                        Compilation: cl -c /W3 /nologo -I. -Iproto -DHAVE_PATHDEF -DWIN32
                        -DFEAT_CSCOPE -DFEAT_NETBEANS_INTG -DFEAT_XPM_W32 /Wp64
                        -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 /Fo.\ObjGOLYTR/ /Ox -DNDEBUG
                        /Zl /MT -DFEAT_OLE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DFEAT_GUI_W32
                        -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_TCL -DDYNAMIC_TCL
                        -DDYNAMIC_TCL_DLL=\"tcl83.dll\" -DDYNAMIC_TCL_VER=\"8.3\"
                        -DFEAT_PYTHON -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python24.dll\"
                        -DFEAT_PERL -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\"perl58.dll\"
                        -DFEAT_RUBY -DDYNAMIC_RUBY -DDYNAMIC_RUBY_VER=18
                        -DDYNAMIC_RUBY_DLL=\"msvcrt-ruby18.dll\" -DFEAT_BIG /Fd.\ObjGOLYTR/
                        /Zi
                        Linking: link /RELEASE /nologo /subsystem:windows oldnames.lib
                        kernel32.lib advapi32.lib shell32.lib gdi32.lib comdlg32.lib
                        ole32.lib uuid.lib /machine:i386 /nodefaultlib gdi32.lib version.lib
                        winspool.lib comctl32.lib advapi32.lib shell32.lib /machine:i386
                        /nodefaultlib libcmt.lib oleaut32.lib user32.lib
                        /nodefaultlib:python24.lib e:\tcl\lib\tclstub83.lib WSock32.lib
                        e:\xpm\lib\libXpm.lib /PDB:gvim.pdb -debug

                        (yes, old version - sorry. Will check if the issue is present on a
                        more recent version, but can't do now).

                        --
                        You received this message from the "vim_use" maillist.
                        Do not top-post! Type your reply below the text you are replying to.
                        For more information, visit http://www.vim.org/maillist.php
                      • Ben Fritz
                        ... That is weird, not what I d expect at all. I ve duplicated in: VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 6 2012 07:36:47) MS-Windows 32-bit GUI
                        Message 11 of 15 , Jun 7, 2012
                        • 0 Attachment
                          On Thursday, June 7, 2012 9:09:16 AM UTC-5, Karthick wrote:
                          > I tried doing this and ran into an issue..
                          >
                          > The script:
                          > au TabEnter * call TabEnterFunc()
                          > au TabLeave * call TabLeaveFunc()
                          >
                          > func! TabEnterFunc()
                          > echo 'Enter: ' . tabpagenr("$")
                          > sleep 1
                          > endfunc
                          >
                          > func! TabLeaveFunc()
                          > echo 'Leave: ' . tabpagenr("$")
                          > sleep 1
                          > endfunction
                          >
                          > If a new tab is created with:
                          > :tabnew
                          > the prints are,
                          > Leave: 1
                          > Enter: 2
                          > (i.e, the number of tabs on TabEnter is one more than when TabLeave
                          > triggered). This is good.
                          >
                          > But when we quit a tab with :q, we get,
                          > Leave: 2
                          > Enter: 2
                          >
                          > Shouldn't the number of buffers as returned by tabpagenr("$") be
                          > up-to-date by the time TabEnter gets triggered?
                          >
                          > :version
                          > VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Aug 9 2008 18:46:22)
                          > MS-Windows 32-bit GUI version with OLE support
                          > Compiled by Bram@KIBAALE
                          > Big version with GUI.

                          That is weird, not what I'd expect at all. I've duplicated in:

                          VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Jun 6 2012 07:36:47)
                          MS-Windows 32-bit GUI version with OLE support
                          Included patches: 1-540
                          Compiled by digitectNO@...
                          Huge version with GUI.

                          The BufEnter event is also too early.

                          I wonder if the new QuitPre autocmd event introduced in 7.3.544 would allow this to work. I'm not 100% sure you could reliably detect a :tabclose event though using it (maybe I'll try later at home where I compile my own Vim).

                          --
                          You received this message from the "vim_use" maillist.
                          Do not top-post! Type your reply below the text you are replying to.
                          For more information, visit http://www.vim.org/maillist.php
                        • Christian Brabandt
                          Hi Ben! ... Bram, the problem is, that enter_tabpage() is called when still both tabpages are valid (before freeing that tabpage), so tabpagenr() returns the
                          Message 12 of 15 , Jun 9, 2012
                          • 0 Attachment
                            Hi Ben!

                            On Do, 07 Jun 2012, Ben Fritz wrote:

                            > On Thursday, June 7, 2012 9:09:16 AM UTC-5, Karthick wrote:
                            > > I tried doing this and ran into an issue..
                            > >
                            > > The script:
                            > > au TabEnter * call TabEnterFunc()
                            > > au TabLeave * call TabLeaveFunc()
                            > >
                            > > func! TabEnterFunc()
                            > > echo 'Enter: ' . tabpagenr("$")
                            > > sleep 1
                            > > endfunc
                            > >
                            > > func! TabLeaveFunc()
                            > > echo 'Leave: ' . tabpagenr("$")
                            > > sleep 1
                            > > endfunction
                            > >
                            > > If a new tab is created with:
                            > > :tabnew
                            > > the prints are,
                            > > Leave: 1
                            > > Enter: 2
                            > > (i.e, the number of tabs on TabEnter is one more than when TabLeave
                            > > triggered). This is good.
                            > >
                            > > But when we quit a tab with :q, we get,
                            > > Leave: 2
                            > > Enter: 2
                            > >
                            > > Shouldn't the number of buffers as returned by tabpagenr("$") be
                            > > up-to-date by the time TabEnter gets triggered?
                            > >
                            > > :version
                            > > VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Aug 9 2008 18:46:22)
                            > > MS-Windows 32-bit GUI version with OLE support
                            > > Compiled by Bram@KIBAALE
                            > > Big version with GUI.

                            Bram,
                            the problem is, that enter_tabpage() is called when still both tabpages
                            are valid (before freeing that tabpage), so tabpagenr() returns the
                            wrong number in case of the :tabclose command.

                            Attached is a patch, that fixes it.

                            regards,
                            Christian

                            --
                            You received this message from the "vim_use" maillist.
                            Do not top-post! Type your reply below the text you are replying to.
                            For more information, visit http://www.vim.org/maillist.php
                          • Bram Moolenaar
                            ... Thanks, I ll check it out. -- So this is it, said Arthur, we are going to die. Yes, said Ford, except...no! Wait a minute! He suddenly lunged
                            Message 13 of 15 , Jun 9, 2012
                            • 0 Attachment
                              Christian Brabandt wrote:

                              > On Do, 07 Jun 2012, Ben Fritz wrote:
                              >
                              > > On Thursday, June 7, 2012 9:09:16 AM UTC-5, Karthick wrote:
                              > > > I tried doing this and ran into an issue..
                              > > >
                              > > > The script:
                              > > > au TabEnter * call TabEnterFunc()
                              > > > au TabLeave * call TabLeaveFunc()
                              > > >
                              > > > func! TabEnterFunc()
                              > > > echo 'Enter: ' . tabpagenr("$")
                              > > > sleep 1
                              > > > endfunc
                              > > >
                              > > > func! TabLeaveFunc()
                              > > > echo 'Leave: ' . tabpagenr("$")
                              > > > sleep 1
                              > > > endfunction
                              > > >
                              > > > If a new tab is created with:
                              > > > :tabnew
                              > > > the prints are,
                              > > > Leave: 1
                              > > > Enter: 2
                              > > > (i.e, the number of tabs on TabEnter is one more than when TabLeave
                              > > > triggered). This is good.
                              > > >
                              > > > But when we quit a tab with :q, we get,
                              > > > Leave: 2
                              > > > Enter: 2
                              > > >
                              > > > Shouldn't the number of buffers as returned by tabpagenr("$") be
                              > > > up-to-date by the time TabEnter gets triggered?
                              > > >
                              > > > :version
                              > > > VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Aug 9 2008 18:46:22)
                              > > > MS-Windows 32-bit GUI version with OLE support
                              > > > Compiled by Bram@KIBAALE
                              > > > Big version with GUI.
                              >
                              > Bram,
                              > the problem is, that enter_tabpage() is called when still both tabpages
                              > are valid (before freeing that tabpage), so tabpagenr() returns the
                              > wrong number in case of the :tabclose command.
                              >
                              > Attached is a patch, that fixes it.

                              Thanks, I'll check it out.

                              --
                              "So this is it," said Arthur, "we are going to die."
                              "Yes," said Ford, "except...no! Wait a minute!" He suddenly lunged across
                              the chamber at something behind Arthur's line of vision. "What's this
                              switch?" he cried.
                              "What? Where?" cried Arthur, twisting around.
                              "No, I was only fooling," said Ford, "we are going to die after all."
                              -- Douglas Adams, "The Hitchhiker's Guide to the Galaxy"

                              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
                              /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
                              \\\ an exciting new programming language -- http://www.Zimbu.org ///
                              \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

                              --
                              You received this message from the "vim_use" maillist.
                              Do not top-post! Type your reply below the text you are replying to.
                              For more information, visit http://www.vim.org/maillist.php
                            • mMontu
                              Ben Fritz wrote ... Following this suggestion I ended with the following code: augroup FocusOnTabClose au! au TabLeave * call TabCloseLeave() au TabEnter *
                              Message 14 of 15 , Jul 30 12:20 PM
                              • 0 Attachment
                                Ben Fritz wrote
                                > But, you might be able to hack a TabLeave/TabEnter autocmd to do things
                                > automatically

                                Following this suggestion I ended with the following code:

                                augroup FocusOnTabClose
                                au!
                                au TabLeave * call TabCloseLeave()
                                au TabEnter * call TabCloseEnter()
                                augroup END
                                function! TabCloseLeave()
                                " Vim default behavior is fine for the first and the last tab
                                if tabpagenr() != 1 && tabpagenr() != tabpagenr('$')
                                augroup TabCloseBufWinLeave
                                au!
                                autocmd BufWinLeave * let g:TabClosedFlag = 1
                                augroup END
                                endif
                                endfunction
                                function! TabCloseEnter()
                                if exists("#TabCloseBufWinLeave")
                                au! TabCloseBufWinLeave
                                endif
                                if exists('g:TabClosedFlag')
                                unlet! g:TabClosedFlag
                                tabprev
                                endif
                                endfunction

                                It is based on the observation that there is a BufWinLeave event between the
                                TabLeave and TabEnter events when tabpgage is closed.



                                --
                                View this message in context: http://vim.1045645.n5.nabble.com/Tab-Order-tp5708299p5722304.html
                                Sent from the Vim - General mailing list archive at Nabble.com.

                                --
                                --
                                You received this message from the "vim_use" maillist.
                                Do not top-post! Type your reply below the text you are replying to.
                                For more information, visit http://www.vim.org/maillist.php

                                ---
                                You received this message because you are subscribed to the Google Groups "vim_use" group.
                                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                                For more options, visit https://groups.google.com/d/optout.
                              • Paul
                                ... For me, with the above in tab.vim: vim -u NONE -p 1 2 3 Places me in tab 1 ... 3gt Places me in tab 3 ... -- -- You received
                                Message 15 of 15 , Jul 31 3:16 PM
                                • 0 Attachment
                                  On Wednesday, 30 July, 2014 at 20:20:38 BST, mMontu wrote:
                                  >augroup FocusOnTabClose
                                  > au!
                                  > au TabLeave * call TabCloseLeave()
                                  > au TabEnter * call TabCloseEnter()
                                  >augroup END
                                  >function! TabCloseLeave()
                                  > " Vim default behavior is fine for the first and the last tab
                                  > if tabpagenr() != 1 && tabpagenr() != tabpagenr('$')
                                  > augroup TabCloseBufWinLeave
                                  > au!
                                  > autocmd BufWinLeave * let g:TabClosedFlag = 1
                                  > augroup END
                                  > endif
                                  >endfunction
                                  >function! TabCloseEnter()
                                  > if exists("#TabCloseBufWinLeave")
                                  > au! TabCloseBufWinLeave
                                  > endif
                                  > if exists('g:TabClosedFlag')
                                  > unlet! g:TabClosedFlag
                                  > tabprev
                                  > endif
                                  >endfunction
                                  >
                                  >It is based on the observation that there is a BufWinLeave event between the
                                  >TabLeave and TabEnter events when tabpgage is closed.

                                  For me, with the above in tab.vim:

                                  vim -u NONE -p 1 2 3 " Places me in tab 1
                                  :source tab.vim
                                  3gt " Places me in tab 3
                                  :q " Places me in tab 2

                                  --
                                  --
                                  You received this message from the "vim_use" maillist.
                                  Do not top-post! Type your reply below the text you are replying to.
                                  For more information, visit http://www.vim.org/maillist.php

                                  ---
                                  You received this message because you are subscribed to the Google Groups "vim_use" group.
                                  To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                                  For more options, visit https://groups.google.com/d/optout.
                                Your message has been successfully submitted and would be delivered to recipients shortly.