Modes
Normal mode: The default mode for most commands.
Insert mode: Used for entering text.
Visual mode: Used for selecting text.
Basic Cursor Movements
Character-based movements:
h
: Move leftj
: Move downk
: Move upl
: Move right
Word-based movements:
w
: Move to the start of the next worde
: Move to the end of the current wordb
: Move to the start of the previous word
Line-based movements:
gg
: Go to the first lineG
: Go to the last line0
: Go to the beginning of the line^
: Go to the first non-blank character of the line$
: Go to the end of the line
Editing
Basic editing:
i
: Enter insert mode before the cursora
: Enter insert mode after the cursorx
: Delete the character under the cursordd
: Delete the current linedw
: Delete from the cursor to the next wordde
: Delete from the cursor to the end of the current worddiw
: Delete the current word (regardless of cursor position)
Yanking (copying):
y
: Yank (copy) the selected textyy
: Yank the current lineyw
: Yank the current word
Pasting:
p
: Paste the yanked textP
: Paste the yanked text before the cursor
Undo/Redo:
u
: Undo the last edit<CTRL-r>
: Redo the last undo
Joining lines:
J
: Join lines
Searching
Basic searching:
/pattern
: Search forward for a pattern?pattern
: Search backward for a patternn
: Go to the next search resultN
: Go to the previous search result
Word-based searching:
*
: Search for the word under the cursor#
: Search backward for the word under the cursor
Visual Mode
Line mode:
v
: Enter visual line mode
Block mode:
<CTRL-v>
: Enter visual block mode
Editing in visual mode:
J
: Join linesx
: Cut selected texty
: Yank selected textr
: Replace selected text with a characterI
: Enter insert mode at the beginning of the selected blockA
: Enter insert mode at the end of the selected block
Other Commands
Window navigation:
zz
: Center the current line in the window
Character searching:
f{char}
: Find the next occurrence of the characterF{char}
: Find the previous occurrence of the charactert{char}
: Move to the character before the next occurrence of the characterT{char}
: Move to the character before the previous occurrence of the character
Brace/parenthesis matching:
%
: Jump to the matching brace or parenthesis[{
: Jump to the opening brace or parenthesis]}
: Jump to the closing brace or parenthesis
Text manipulation:
ci{symbol}
: Change text within the specified symbolscit
: Change text within HTML tagsgcc
: Comment or uncomment the current linegc{motion}
: Comment or uncomment the selected lines>>
: Indent the current line<<
: Unindent the current line
Number manipulation:
<CTRL-a>
: Increment the number under the cursor<CTRL-x>
: Decrement the number under the cursor
Marks:
m{mark}
: Set a mark{mark}
: Go to the specified mark
Reference:
If you are looking for a tutorial on VIM. Check out this VIM course from Zero To Mastery Academy by Jayson Lennon.