Skip to content

Instantly share code, notes, and snippets.

@x1unix
Last active May 29, 2020 17:21
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 x1unix/456dab3133e69779d46b96858dc2f4fb to your computer and use it in GitHub Desktop.
Save x1unix/456dab3133e69779d46b96858dc2f4fb to your computer and use it in GitHub Desktop.
The VIM Cheatsheet

The VIM Cheatsheet

https://vim-adventures.com/

https://eax.me/vim-commands/

Most of commands accept number before (eg: 3k moves down 3 times)

modes

  • i - insert mode
  • v - visual, used for text selection

views

  • :open X - Open file
  • :ter[minal] - Open terminal
  • ctrl+w v - Split screen horizontally
  • ctrl+w s - Split vertically
  • ctrl+w l/h/j/k - Switch to right/left/up/down side
  • ctrl+w L/H/J/K - Switch to panel to right/left/up/down
  • ctrl+w </> - Resize panel width
  • ctrl+w +/- - Resize panel height

visual mode commands

  • v - Go to visual mode
  • y - Copy text
  • d - delete selection
  • x - cut selection
  • p, P - paste selection before/after custor (or i in Command mode)
  • dw - delete word
  • V - select line
  • cw - change word
  • C - change whole line
  • D - Delete rest of line from cursor

navigate

  • j, k - ⬆️ ⬇️
  • h, l - ⬅️ ➡️
  • 0, $ - Go to Start/End of the line
  • w, W (or e, E, B) - Move by word
  • b - Back to word
  • gg - Go to end
  • G - Go to end

commands

  • u - ↩️ Undo
  • . - 🔁 Repeat last command
  • Ndd - ❌ Delete N lines
  • x - ❌ Delete char
  • o - ↵ Add a new line
  • A - Insert at the line end

search and replace

  • /text - 🔍 search for text
  • ?text - Search top
  • n, N - Go to next/previous search result
  • :%s/str/rep - Replace str with rep
  • 10G - Go to line 10

bookmarks

  • mx - Create a mark with name x (mark this position)
  • 'x - Jump to mark x

view & layout

  • :split FILE_NAME - Split vertically and open file

macros

  • q1 - Start macros with number 1 (basically record and replay commands)
  • q - Stop macro record
  • @1 - Call macros 1 (or 10@1 to run 10 times)

a few ways to get out of Vim

  • ZZ, :q!, :!kill -9 $PPID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment