Vim Quick Reference
Vim Quick Reference
Quick reference guide for basic Vim commands.
Modes
Vim is a modal editor. The two main modes are:
Normal Mode- Default mode
- Used for navigation, copy, paste, delete, and commands
Insert Mode- Used for typing and editing text
Mode Switching
iβ Enter Insert Mode- Start typing text
Escβ Exit Insert Mode- Return to Normal Mode
Basic Commands
All commands run from Normal Mode.
Saving and Quitting
:wβ Save file- Writes changes to disk
:qβ Quit file- Exit if no unsaved changes
:qaβ Quit all- Close all open files
:wqβ Save & quit- Write and exit
ZZβ Quick save & quit- Same as
:wq
- Same as
:q!β Force quit- Exit without saving
Navigation
hjklβ Cursor movement- Left, down, up, right
0β Line start- Jump to beginning of line
$β Line end- Jump to end of line
ggβ File start- Go to first line
Gβ File end- Go to last line
:20β Jump to line- Goes to line number 20
Editing
oβ New line after- Insert below current line
Oβ New line before- Insert above current line
Sβ Replace line- Delete current line and enter insert mode
uβ Undo- Revert last change
Ctrl + rβ Redo- Re-apply undone change
Copy, Paste, Delete
yyβ Copy line- Yank current line
pβ Paste after- Paste below cursor
Pβ Paste before- Paste above cursor
ddβ Delete line- Remove current line
dwβ Delete word- Delete from cursor to next word
Settings
:set numberβ Show line numbers- Enables numbering
:set nonumberβ Hide line numbers- Disables numbering