Most Used Vim Commands for Daily Coding
For my personal daily references.
Modes
- Normal mode (default) → navigation, editing commands.
- Insert mode → i (insert before cursor), a (append after cursor), o (new line below).
- Visual mode → v (character select), V (line select), Ctrl+v (block select).
- Command-line mode → : for commands (save, quit, search, etc).
Movement
h j k l- Left, down, up, right (basic movement)w b- Jump forward/backward by word0 $- Beginning/end of line^- First non-blank character of linegg G- Go to first/last line of file{ }- Jump between paragraphs/blocksCtrl+u Ctrl+d- Half page up/downCtrl+b Ctrl+f- Full page up/down:n: Go to line numbern:set nu: Show line numbers
Editing Modes
i a- Insert before cursor / Insert after cursorI A- Insert at beginning/end of lineo O- Open new line below/abovev V- Visual mode / Visual line modeCtrl+v- Visual block mode
Essential Editing
x- Delete character under cursordw- Delete worddd- Delete entire lineD- Delete to end of lineyy- Copy (yank) lineyw- Copy (yank) wordp P- Paste after/before cursoru Ctrl+r- Undo/redor- Replace single characterc- Change (delete and enter insert mode).- Repeat last command
Search & Replace
/- Search forward?- Search backwardn N- Next/previous search result:%s/old/new/g- Replace all occurrences in file:s/old/new/g- Replace all occurrences in current line
File Operations
:w- Save the current file:wq- Save and quit:x- Save and quit (alternative):q- Quit Vim:q!- Quit without saving:e filename- Open a file:split filenameor:vsplit filename- Open file in horizontal/vertical split view
Code-Specific
>><<- Indent/unindent line=- Auto-indent selection%- Jump to matching bracket/parenthesis*- Find next occurrence of word under cursor~- Toggle case of character under cursorg~- Toggle case of selected textCtrl+o Ctrl+i- Jump to previous/next location in jump list
Combining Commands
dw- Delete wordd$- Delete to end of liney$- Copy to end of linec$- Change to end of line5dd- Delete 5 lines3w- Move 3 words forward
Window Management
:split- Split window:vsplit- Vertical split windowCtrl+w h/j/k/l- Move between split windows
Last updated on