Vim
Vim Keyboard Shortcuts
Essential Vim keyboard shortcuts - modes, navigation, editing, search, visual mode, buffers, and common commands.
Modes
| Shortcut | Action |
|---|---|
i | Enter Insert mode (before cursor) |
a | Enter Insert mode (after cursor) |
I | Insert at beginning of line |
A | Insert at end of line |
o | Open new line below and enter Insert mode |
O | Open new line above and enter Insert mode |
v | Enter Visual mode (character) |
V | Enter Visual mode (line) |
Ctrl+V | Enter Visual Block mode |
R | Enter Replace mode |
Esc | Return to Normal mode |
: | Enter Command-line mode |
Navigation
| Shortcut | Action |
|---|---|
h / j / k / l | Left / Down / Up / Right |
w | Jump to start of next word |
W | Jump to start of next WORD (whitespace-delimited) |
e | Jump to end of word |
b | Jump to start of previous word |
0 | Jump to beginning of line |
^ | Jump to first non-blank character |
$ | Jump to end of line |
gg | Go to first line |
G | Go to last line |
{number}G | Go to line number |
{ | Jump to previous paragraph |
} | Jump to next paragraph |
Ctrl+D | Scroll down half page |
Ctrl+U | Scroll up half page |
Ctrl+F | Scroll down full page |
Ctrl+B | Scroll up full page |
H | Move to top of screen |
M | Move to middle of screen |
L | Move to bottom of screen |
% | Jump to matching bracket |
f{char} | Find next char on line |
F{char} | Find previous char on line |
t{char} | Jump to before next char on line |
* | Search for word under cursor (forward) |
# | Search for word under cursor (backward) |
Editing
| Shortcut | Action |
|---|---|
x | Delete character under cursor |
X | Delete character before cursor |
dd | Delete (cut) entire line |
dw | Delete word from cursor |
d$ / D | Delete to end of line |
d0 | Delete to beginning of line |
yy | Yank (copy) entire line |
yw | Yank word |
y$ | Yank to end of line |
p | Paste after cursor |
P | Paste before cursor |
cc | Change (delete and enter Insert) entire line |
cw | Change word |
c$ / C | Change to end of line |
ciw | Change inner word |
ci" | Change inside quotes |
ci( | Change inside parentheses |
ca{ | Change around curly braces |
r{char} | Replace single character |
~ | Toggle case |
>> | Indent line |
<< | Outdent line |
. | Repeat last command |
u | Undo |
Ctrl+R | Redo |
J | Join line below with current |
Search & Replace
| Shortcut | Action |
|---|---|
/{pattern} | Search forward |
?{pattern} | Search backward |
n | Next search result |
N | Previous search result |
:%s/old/new/g | Replace all in file |
:%s/old/new/gc | Replace all with confirmation |
:s/old/new/g | Replace all on current line |
:noh | Clear search highlighting |
Visual Mode
| Shortcut | Action |
|---|---|
v | Start character selection |
V | Start line selection |
Ctrl+V | Start block selection |
d | Delete selected text |
y | Yank selected text |
> | Indent selection |
< | Outdent selection |
= | Auto-indent selection |
gv | Reselect last visual selection |
o | Move to other end of selection |
Buffers, Windows & Tabs
| Shortcut | Action |
|---|---|
:e {file} | Open file in new buffer |
:bn / :bp | Next / previous buffer |
:bd | Delete (close) buffer |
:sp | Horizontal split |
:vsp | Vertical split |
Ctrl+W h/j/k/l | Navigate between splits |
Ctrl+W = | Equal size splits |
Ctrl+W _ | Maximize height |
Ctrl+W | | Maximize width |
:tabnew | New tab |
gt / gT | Next / previous tab |
Commands
| Shortcut | Action |
|---|---|
:w | Save file |
:q | Quit |
:wq / ZZ | Save and quit |
:q! / ZQ | Quit without saving |
:wa | Save all buffers |
:x | Save and quit (only writes if changed) |
:!{cmd} | Execute shell command |
:r {file} | Read file into buffer |
:set number | Show line numbers |
:set paste | Enable paste mode |