Skip to content

Instantly share code, notes, and snippets.

@hassanazimi

hassanazimi/Vim.md

Last active May 16, 2019
Embed
What would you like to do?
Vim Cheatsheet! The shortcuts and keys that escape from mind. Rest of the keys are too easy to include.

Global

  • e - jump forwards to the end of a word
  • b - jump backwards to the start of a word
  • 0 - jump to the start of the line
  • $ - jump to the end of the line
  • gg - go to the first line of the document
  • G - go to the last line of the document
  • / - seach and enter
  • } - jump to next paragraph (or function/block, when editing code)
  • { - jump to previous paragraph (or function/block, when editing code)
  • zz - center cursor on screen

Inserting/Appending

  • i - insert before the cursor
  • I - insert at the beginning of the line
  • a - insert (append) after the cursor
  • A - insert (append) at the end of the line
  • o - append (open) a new line below the current line
  • O - append (open) a new line above the current line

Working with multiple files

  • :bn - go to the next buffer
  • :bp - go to the previous buffer
  • :bd - delete a buffer
  • :ls - list all open buffers
  • :sp file - open a file in a new buffer and split window
  • :vsp file - open a file in a new buffer and vertically split window
  • Ctrl + ws - split window
  • Ctrl + ww - switch windows
  • Ctrl + wq - quit a window
  • Ctrl + wv - split window vertically
  • Ctrl + wh - move cursor to the left window (vertical split)
  • Ctrl + wl - move cursor to the right window (vertical split)
  • Ctrl + wj - move cursor to the window below (horizontal split)
  • Ctrl + wk - move cursor to the window above (horizontal split)

Editing

  • r - replace a single character
  • J - join line below to the current one with one space in between
  • cc - change (replace) entire line
  • C - change (replace) to the end of the line
  • ciw - change (replace) entire word
  • cw - change (replace) to the end of the word
  • s - delete character and substitute text
  • S - delete line and substitute text (same as cc)
  • xp - transpose two letters (delete and paste)
  • u - undo
  • . - repeat the command

Visual commands

  • > - shift text right
  • < - shift text left
  • y - yank (copy) marked text
  • d - delete marked text
  • ~ - switch case
  • - - browse directory

Cut and paste

  • yy - yank (copy) a line
  • yw - yank (copy) the characters of the word from the cursor position to the start of the next word
  • p - put (paste) the clipboard after cursor
  • P - put (paste) before cursor
  • dd - delete (cut) a line
  • dw - delete (cut) the characters of the word from the cursor position to the start of the next word
  • D - delete (cut) to the end of the line
  • d$ - delete (cut) to the end of the line
  • x - delete (cut) character
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment