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

Reply via email to