Multiple files can be opened in Vim within the same tab page and/or in different tabs. From :h windows-intro:

  • A buffer is the in-memory text of a file.
  • A window is a viewport on a buffer.
  • A tab page is a collection of windows.
  • :tabe filename open the given file in a new tab (:tabe is short for :tabedit)
    • if filename isn't specified, you'll get an unnamed empty window
    • by default, the new tab is opened to the right of the current tab
    • :0tabe open as the first tab
    • :$tabe open as the last tab
    • see :h :tabe for more details and features

Switching between tabs:

  • :tabn switch to the next tab (:tabn is short for :tabnext)
    • if tabs to the right are exhausted, switch to the first tab
    • gt and Ctrl+Page Down can also be used
    • 2gt switch to the second tab (the number specified is absolute, not relative)
  • :tabp switch to the previous tab (:tabp is short for :tabprevious)
    • if tabs to the left are exhausted, switch to the last tab
    • gT and Ctrl+Page Up can also be used
  • :tabr switch to the first tab (:tabr is short for :tabrewind)
    • :tabfirst can also be used
  • :tabl switch to the last tab (:tabl is short for :tablast)

Moving tabs:

  • :tabm N move the current tab to after N tabs from the start (:tabm is short for :tabmove)
    • :tabm 0 move the current tab to the beginning
    • :tabm move the current tab to the end
  • :tabm +N move the current tab N positions to the right
  • :tabm -N move the current tab N positions to the left

info Buffer list includes all the files opened in all the tabs. You can also use the mouse to switch/move tabs in GVim.

Video demo:


info See also my Vim Reference Guide and curated list of resources for Vim.