DevTools
Vim
Vim editor commands and shortcuts for efficient text editing.
48 commands
Windows
MacOS
Linux
#text-editor
#productivity
Mode Switching
Enter insert mode before cursor
i
Enter insert mode after cursor
a
Open new line below and enter insert mode
o
Open new line above and enter insert mode
O
Return to normal mode
Esc
Enter visual character mode
v
Enter visual line mode
V
Enter replace mode
R
Navigation
Move left, down, up, right
h j k l
Jump forward to start of next word
w
Jump backward to start of previous word
b
Jump forward to end of current word
e
Jump to beginning of line
0
Jump to end of line
$
Go to the first line of the file
gg
Go to the last line of the file
G
Editing
Delete the current line
dd
Yank (copy) the current line
yy
Paste after cursor position
p
Paste before cursor position
P
Undo the last change
u
Redo the last undone change
Ctrl+r
Delete character under cursor
x
Change word from cursor to end
cw
Search & Replace
Search forward for pattern
/pattern
Search backward for pattern
?pattern
Jump to next search match
n
Jump to previous search match
N
Replace all on current line
:s/old/new/g
Replace all in entire file
:%s/old/new/g
Replace all with confirmation prompt
:%s/old/new/gc
File Operations
Save the current file
:w
Quit Vim
:q
Save and quit
:wq
Quit without saving changes
:q!
Open a file for editing
:e filename
Save as a new filename
:w filename
Insert contents of a file
:r filename
Visual Mode
Select text character by character
v + motion
Select text line by line
V + motion
Enter visual block mode for columns
Ctrl+v
Delete the selected text
d
Yank (copy) the selected text
y
Indent selected lines right
>
Indent selected lines left
<
Quick Commands
Replace all occurrences in the entire file
:%s/old/new/g
Save the file and quit Vim
:wq
Delete the current line
dd