Published
- 2 min read
Vim Cheatsheet
Vim Keyboard Shortcut Cheatsheet
Navigation
h
: Move leftj
: Move downk
: Move upl
: Move right
Basic Editing
i
: Insert mode before the cursora
: Insert mode after the cursoro
: Open a new line below the current lineO
: Open a new line above the current linex
: Delete the character under the cursordd
: Delete the current lineyy
: Yank (copy) the current linep
: Paste the yanked or deleted text after the cursoru
: UndoCtrl + r
: Redo
Saving and Exiting
:w
: Save (write) the file:q
: Quit (close) Vim:wq
orZZ
: Save and quit
Search and Replace
/pattern
: Search for a patternn
: Move to the next search resultN
: Move to the previous search result:s/old/new/g
: Replace all occurrences of ‘old’ with ‘new’ in the entire file
Visual Mode
v
: Enter visual modeV
: Enter visual line modeCtrl + v
: Enter visual block mode
Advanced Navigation
w
: Move forward by a wordb
: Move backward by a worde
: Move to the end of a word%
: Jump to matching parenthesis, bracket, or bracet<char>
: Move to the next occurrence of<char>
Window Management
:split
: Split the window horizontally:vsplit
: Split the window verticallyCtrl + w, w
: Switch between windowsCtrl + w, h/j/k/l
: Navigate between windows
Miscellaneous
:help keyword
: Open help for a keyword:q!
: Quit without saving changes:set number
: Show line numbers:set nonumber
: Hide line numbers:set ignorecase
: Ignore case when searching:set smartcase
: Case-sensitive if search pattern contains an uppercase letter