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

(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

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 PirocchiApr 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.– garyjohnApr 11 '12 at 5:00
I found it very convenient to use '<' and '>'– Igor StoppaFeb 22 '16 at 16:14
Scroll down for a better answer..– The VivandiereSep 9 '16 at 18:09

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

" Go to tab by numbernoremap <leader>1 1gtnoremap <leader>2 2gtnoremap <leader>3 3gtnoremap <leader>4 4gtnoremap <leader>5 5gtnoremap <leader>6 6gtnoremap <leader>7 7gtnoremap <leader>8 8gtnoremap <leader>9 9gtnoremap <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., <c-l>):

" Go to last active tabau TabLeave * let g:lasttab=tabpagenr()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
I'd add <leader>h/l for gT and gt– BrendenApr 7 '16 at 20:13

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
I think this is the best answer here. Very convenient to have. I just disabled those system keybindings in OS X for making them system independent.– Léo Léopold Hertz 준영May 14 '16 at 5:47
Use arrow keys will slow you down. I have them disabled– Ask and LearnJul 19 '16 at 5:03
Yup... Best answer!– The VivandiereSep 9 '16 at 18:08
Sadly "Ctrl" gave me problems in vmplayer, so I changed to keys "Backspace" and "Enter".– Boris DäppenJul 13 '17 at 11:30
Mac users: you may need to disable the default Mission Control spaces keyboard shortcuts:…– toszterAug 29 '17 at 22:52

As I am on a Mac and not using MacVim (but plain vim within a terminal) I have had some difficulty with key combinations not being sent through to the terminal.

The most-compatible (and for me most comfortable) way to switch tabs quickly comes from the Vim Wikia site.

Place in your .vimrc file:

nnoremap H gTnnoremap L gt

Now Shift-h (capital H) and Shift-l (capital L) will switch you quickly between tabs, and follows the convention that h and l correspond to left and right in vim on a regular qwerty keyboard.

share|improve this answer

If you're using gvim or similar (i.e., something outside of the terminal), you can imitate the gnome-terminal behaviour you describe with:

" Map alt-x keys to jump to a tabfor i in range(1, 8)execute "nmap \<M-" . i . "> " . i . "gt"endfornmap <M-9> :tablast<CR>

So alt-1 jumps to the first tab, etc. But alt-9 jumps to the last tab (as in Chrome).

You might want to wrap this in if has("gui_running") (although this doesn't seem to work with Neovim), or put this in .gvimrc.

share|improve this answer

Here are a couple easy mappings for your .vimrc:

nnoremap <C-h> :tabprevnnoremap <C-l> :tabnext


  • No moving from the home row (I swap ctrl and caps lock)
  • Reuses the "left" and "right" keys
  • Feels similar to switching browser tabs
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.