" -- tab switching -- nmap gT xmap gT imap gT nmap gT xmap gT nmap gt xmap gt imap gt nmap 1 1gt nmap 2 2gt nmap 3 3gt nmap 4 4gt nmap 5 5gt nmap 6 6gt nmap 7 7gt nmap 8 8gt nmap 9 9gt nmap 0 10gt nmap :tabfirst xmap :tabfirst imap :tabfirst nmap :tablast xmap :tablast imap :tablast " Original literal behaviour (improved by JumpBetweenTabs()) noremap g g xnoremap g g " Open the next/previous buffer in a new tab nmap :tab sbnext nmap :tab sbprevious if exists('*function') " can't use because that can't handle a count " have to use the to avoid passing the count to :call nmap g :call JumpBetweenTabs(v:count) xmap g :call JumpBetweenTabs(v:count) let g:previous_tab = 1 " When no count is supplied, switch to the previous tab where this function " was called. When a count is supplied, act like "gt". " (Note that "gt" effectively forgets the current tab, so afterwards, this " function without a count will go back to the previous-previous tab.) function! JumpBetweenTabs(count) if a:count > 0 let g:previous_tab = tabpagenr() exe ":tabn" a:count else " have to figure things out first, because :exe must happen last let l:new_tab = g:previous_tab let g:previous_tab = tabpagenr() exe ":tabn" l:new_tab endif endfunction endif