Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@wout
Forked from Starefossen/vim-cheats.md
Created August 20, 2022 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wout/58ae6cd662a15b2ca1ddca6223566238 to your computer and use it in GitHub Desktop.
Save wout/58ae6cd662a15b2ca1ddca6223566238 to your computer and use it in GitHub Desktop.
My vim cheat sheet for working with tabs and window splits.

Tabs

New Tab

  • :tabnew - new blank tab
  • :tabedit [file] - open file in tab

Cursor Movement

  • gt (:tabn) - next tab
  • gT (:tabp) - previous tab
  • [i]gt - go to tab [i]

Tabs Management

  • :tabs - list open tabs
  • :tabm 0 - move current tab to first position
  • :tabm - move current tab to last position
  • :tabm [i] - move current tab to position [i]

Close Tab

  • :tabc - close current tab
  • :tabo - close all other tabs

Window Split

New Split

Pro-Tip: control splitting directionality by setting splitright and splitbelow options.

  • <C-w>n (:new [file]) - split horizontaly
  • <C-w>s (:split [file]) - split horizontaly
  • <C-w>v (:vsplit [file]) - split verticaly

Cursor Movement

  • <C-w>w - next split
  • <C-w>p - previous split
  • <C-w><Up> - move above
  • <C-w><Down> - move bellow
  • <C-w><Left> - move left
  • <C-w><Right> - move right

Splits Movement

  • <C-w>r - rotate to the right
  • <C-w>H - move to the left
  • <C-w>J - move to the bottom
  • <C-w>K - move to the top
  • <C-w>L - move to the right
  • <C-w>T - (:tab split) move split to new tab

Resize Split

  • <C-w>p + - increase height
  • <C-w>p - - decrease height
  • <C-w>p < - increase width
  • <C-w>p > - decrease width

Close Split

  • <C-w>c (:close) - close split
  • <C-w>q (:q) - close split and quit file
  • <C-w>o (:only) - close all other splits

Sources

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment