After closing a tab in vim, how do I make it so that the tab to the left is the one automatically shown?
The default when closing a tab seems to be showing the right tab, which is annoying because new tabs OPEN on the right of your current tab. So opening a new tab and closing it leaves you on a different tab.
You can type Ctrl-W c to close the current window. If that window is the last window visible in a tab, the tab is also closed (if another tab page is currently open).
You can use :tabmove followed by the tab number to move past. For example, :tabmove 3 will make the current tab move past the 3rd. :tabmove 0 moves to the beginning and :tabmove (without a number) moves to the end.
Esc + :qa + Enter (Quit all open files) Esc + Shift ZZ (Save and exit) Esc + Shift ZQ (Exit without saving)
A patch has been proposed to add a 'tabcloseleft' option; it is on the todo list to be integrated into Vim (some time in the future, once Bram has time to work on it).
There is one idea: though there is no TabClose
event there is TabEnter
event which could be used to achieve what you want: if on one of the events number of tabs is less then previously recorded number then obviously it was triggered due to closed tab:
let s:prevtabnum=tabpagenr('$')
augroup TabClosed
autocmd! TabEnter * :if tabpagenr('$')<s:prevtabnum && tabpagenr()>1
\ | tabprevious
\ |endif
\ |let s:prevtabnum=tabpagenr('$')
augroup END
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With