vimtricks.wiki Concise Vim tricks, one at a time.

How do I switch between tab pages?

Answer

gt and gT

Explanation

The gt command moves to the next tab page and gT moves to the previous one. Tab pages are the outermost container in Vim's window hierarchy.

How it works

  • gt goes to the next tab
  • gT goes to the previous tab
  • {count}gt goes to tab number N (1-indexed)

Example

With three tabs open:

  • gt moves from tab 1 to tab 2
  • gt again moves to tab 3
  • gT moves back to tab 2
  • 1gt jumps to tab 1

Tips

  • :tabnext and :tabprev are the Ex command equivalents
  • :tabs lists all tab pages and their windows
  • :tabfirst and :tablast jump to the extremes
  • Map <leader>1 through <leader>9 for quick tab access
  • <C-PageDown> and <C-PageUp> also switch tabs in some terminals

Next

How do you yank a single word into a named register?