Cursor movement [+/-] Command Mode
h-- move leftj-- move downk-- move upl-- move rightw-- jump by start of wordsW-- jump by wordse-- jump to end of wordsE-- jump to end of wordsb-- jump backward by wordsB-- jump backward by words0-- (zero) start of line^-- first non-blank character of line$-- end of lineG-- Go To command (5G goes to line 5)
Notes
- Prefix a cursor movement command with a number to repeat it. For example, 4j moves down 4 lines.
- Capital letters skip punctuation.
- Spaces separate words.
Inserting/Appending [+/-] Insert Mode
i-- start insert mode at cursorI-- insert at the beginning of the linea-- append after the cursorA-- append at the end of the lineo-- open (append) blank line below current line (no need to press return)O-- open blank line above current lineea-- append at end of wordEsc-- exit insert mode
Cut and Paste [+/-] Command Mode
yy-- yank (copy) a line2yy-- yank 2 linesyw-- yank wordy$-- yank to end of linep-- put (paste) the clipboard after cursorP-- put (paste) before cursordd-- delete (cut) a linedw-- delete (cut) the current wordx-- delete (cut) current character
Search/Replace [+/-] Command Mode
/pattern-- search for pattern?pattern-- search backward for patternn-- repeat search in same directionN-- repeat search in opposite direction:%s/old/new/g-- replace all old with new throughout file:%s/old/new/gc-- replace all old with new throughout file with confirmations
Editing [+/-] Command Mode
r-- replace a single character (does not use insert mode)J-- join line below to the current onecc-- change (replace) an entire linecw-- change (replace) to the end of wordc$-- change (replace) to the end of lines-- delete character at cursor and subsitute textS-- delete line at cursor and substitute text (same as cc)xp-- transpose two letters (delete and paste, technically)u-- undo.-- repeat last command
Exiting [+/-] Command Mode
:w-- write (save) the file, but don't exit:wq-- write (save) and quit:q-- quit (fails if anything has changed):q!-- quit and throw away changes
Marking Text [+/-] Visual Mode
v-- start visual mode, mark lines, then do command (such as y-yank)V-- start Linewise visual modeo-- move to other end of marked areaCtrl+v-- start visual block modeO-- move to Other corner of blockaw-- mark a wordab-- a () block (with braces)aB-- a {} block (with brackets)ib-- inner () blockiB-- inner {} blockEsc-- exit visual mode
Visual commands [+/-] Visual Mode
>-- shift right<-- shift lefty-- yank (copy) marked textd-- delete marked text~-- switch case
Working with multiple files [+/-] Command Mode
:e filename-- Edit a file in a new buffer:bnext (or :bn)-- go to next buffer:bprev (of :bp)-- go to previous buffer:bd-- delete a buffer (close a file):sp filename-- Open a file in a new buffer and split windowctrl+ws-- Split windowsctrl+ww-- switch between windowsctrl+wq-- Quit a windowctrl+wv-- Split windows vertically