VIM cheatsheet

Exiting:

  • :qa ⇒ close alll file
  • :qa! ⇒ close all files, abadon changes
  • :w ⇒ save
  • :wq / :x ⇒ Save and close file
  • :q ⇒ close file
  • :q! ⇒ close files, abadon changes
  • ZZ ⇒ save and quit
  • ZQ ⇒ quit without checking changes

Navigation:

  • h, j, k, l ⇒ arrow keys
  • / ⇒ Half-page up / down
  • / ⇒ page up / down

words

  • b / w ⇒ previus / next word
  • ge / e ⇒ previus / next end of word

line

  • 0 (zero) ⇒ start of line
  • ^ ⇒ start of line (after white space)
  • $ ⇒ end of line

character

  • fc ⇒ go forward to character c
  • FC ⇒ go backword to character c

document

  • gg ⇒ first line
  • G ⇒ last line
  • :n ⇒ go to line n
  • nG ⇒ go to line n

window

  • zz ⇒ center this line
  • zt ⇒ top this line
  • zb ⇒ bottom this line
  • H ⇒ move to top of the screen
  • M ⇒ move to middle of the screen
  • L ⇒ move to bottom of screen

search

  • n ⇒ next matching search pattern
  • N ⇒ pervius match
  • *⇒ next whole word under cursor
  • ⇒ pervius whole word under cursor

tab pages

  • :tabedit [file] ⇒ edit file in new tab
  • :tabfind [file] ⇒ open file if exist in new tab
  • :tabclose ⇒ close current tab
  • :tabs ⇒ list all tabs
  • :tabfirst ⇒ go to first tab
  • :tablast ⇒ go to last tab
  • :tabn ⇒ go to next tab
  • :tabp ⇒ go to previus tab

Editing:

  • a ⇒ append
  • A ⇒ append from end of line
  • i ⇒ insert
  • o ⇒ next line
  • O ⇒ previus line
  • s ⇒ delete char and insert
  • S ⇒ delete line and insert
  • C ⇒ delete until end of line and insert
  • r ⇒ replace one character
  • R ⇒ enter replace mode
  • u ⇒ undo changes
  • ⇒ redo changes

Clipbord:

  • x ⇒ delete character
  • dd ⇒ delete line (cut)
  • yy ⇒ yank line (copy)
  • p ⇒ paste
  • P ⇒ paster before
  • "+p / "*p ⇒ paste from system clipborad
  • "+y / "*y ⇒ copy to system clipborad

Exiting insert mode:

  • Esc / ⇒ exit insert mode
  • ⇒ exit insert mode and abort current command

Visual mode:

  • v ⇒ enter visual mode
  • V ⇒ enter visual line mode
  • ⇒ enter visual block mode

in visual mode

  • d / x ⇒ delete selection
  • s ⇒ replace selection
  • y ⇒ yank selection (copy)