You can have multiple windows within the same tab page.

  • :split filename open file for editing in a new horizontal window, above the current window
    • you can also use :sp instead of :split
    • :set splitbelow open horizontal splits below the current window
  • :vsplit filename open file for editing in a new vertical window, to the left of the current window
    • you can also use :vs instead of :vsplit
    • :set splitright open vertical splits to the right of the current window

Here are some shortcuts to navigate between windows:

  • Ctrl+w followed by w switch to the below/right window for horizontal/vertical splits respectively
    • Ctrl+w followed by Ctrl+w also performs the same function
    • switches to the first split if you are on the last split
  • Ctrl+w followed by W switch to the above/left window for horizontal/vertical splits respectively
    • switches to the last split if you are on the first split
  • Ctrl+w followed by hjkl or arrow keys, switch in the respective direction
  • Ctrl+w followed by t or b switch to the top (first) or bottom (last) window
  • Ctrl+w followed by HJKL (uppercase), moves the current split to the farthest possible location in the respective direction

info If filename is not provided, the current one is used.

info Vim adds a highlighted horizontal bar containing the filename for each split.

Video demo:


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