Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In gnome-terminal, I can just press Alt + (1, 2, 3, etc.) to switch to specific tabs. I can also use Ctrl + (PgUp / PgDn) to cycle through tabs (admittedly less convenient, but it can be remapped).

If I want to use vim tabs instead of gnome-terminal tabs, typing :tabn and :tabp is quite cumbersome. I could map them to keyboard shortcuts, but that is still a lot less convenient than jumping directly to tab 4 with Alt + 4.

Is there a faster way to switch between tabs in vim?

share|improve this question

Next tab: gt

Prior tab: gT

Numbered tab: nnngt

share|improve this answer
I know that I could type nnn g t, but I want to do it quickly, i.e. Alt + nnn or Ctrl + nnn. But Alt + n is already taken by gnome-terminal, and binding to Ctrl + n doesn't seem to have any effect. – Matthew Pirocchi Apr 11 '12 at 2:46
What about mapping function keys to nnn g t? E.g., :map <F2> 2gt. There is the problem that <F1> is often mapped by GNOME to its help facility. Or you could choose some key you don't use often in normal mode, say the comma, and map it like this: :map , gt. Then 1, will take you to tab 1, 2, to tab 2, and so on. – garyjohn Apr 11 '12 at 5:00

Why not make use of your leader (my leader is mapped to space):

" Go to tab by number
noremap <leader>1 1gt
noremap <leader>2 2gt
noremap <leader>3 3gt
noremap <leader>4 4gt
noremap <leader>5 5gt
noremap <leader>6 6gt
noremap <leader>7 7gt
noremap <leader>8 8gt
noremap <leader>9 9gt
noremap <leader>0 :tablast<cr>

You can use the settings below to toggle between the current and last active tab (here it is mapped to ctrl+l, i.e. "ell"):

" Go to last active tab

nnoremap <silent> <c-l> :exe "tabn ".g:lasttab<cr>
vnoremap <silent> <c-l> :exe "tabn ".g:lasttab<cr>
share|improve this answer
You need au TabLeave * let g:lasttab = tabpagenr() for c-l to work:… – Ciro Santilli 六四事件 法轮功 包卓轩 Oct 16 '14 at 12:31

This is the easiest way that I found, to switch between tabs faster and simple.
Add next lines to your .vimrc and enjoy it, more tricks about vim tabs here.

nnoremap <C-Left> :tabprevious<CR>
nnoremap <C-Right> :tabnext<CR>

Now you can use Ctrl to go left and Ctrl to go right.

Or just use:
1gt to go to tab one,
2gt to go to tab two,
3gt to go to tab three, etc... now you have the idea.

share|improve this answer

(Unfortunately) vim also uses CtrlPgDn/PgUp to cycle through tabs. You'll need to use map to map tabn/tabp to something usable.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.