- Published on
Vim Cheatsheet
- Authors
- Name
- Noah Love
- @noahjameslove
Scroll to the bottom for the "basics." Section in the middle is for commands that I thought were helpful in vim terminal but never use in VS Code.
My favorites
Editing & Deleting Text
Shortcut | Summary | Description |
---|---|---|
yy | Yank line | Copy the current line |
dd | Delete line | Delete the current line |
p | Paste after | Paste after the cursor |
P | Paste before | Paste before the cursor |
x | Delete char | Delete character under the cursor |
diw | Delete inner word | Delete word under the cursor |
dw | Delete word | Delete from cursor to end of word |
daw | Delete a word | Delete from cursor to end of word and space after |
Advanced Editing Commands
Shortcut | Summary | Description |
---|---|---|
y | Yank | Copy selection |
d | Delete | Delete selection |
cc | Change line | Change the entire current line |
cw | Change word | Change from the cursor to end of the word |
ciw | Change inner word | Change the word under the cursor |
s | Substitute char | Delete char under cursor & enter Insert mode |
Modes & Selection
Shortcut | Summary | Description |
---|---|---|
i | Insert mode | Enter insert mode before the cursor |
a | Append mode | Enter insert mode after the cursor |
o | Open below | Open a new line below and enter insert mode |
O | Open above | Open a new line above and enter insert mode |
v | Visual select | Enter visual mode for character selection |
V | Visual line | Enter visual mode for line selection |
Search & Navigation
Shortcut | Summary | Description |
---|---|---|
f | Find char in line | Find next occurrence of character in line |
F | Find char backward in line | Find previous occurrence of character in line |
/ | Search | Search for a pattern in the file |
n | Next match | Jump to the next match |
N | Previous match | Jump to the previous match |
ctrl+u | Up half-screen | Move up half a screen |
ctrl+d | Down half-screen | Move down half a screen |
ctrl+b | Back one screen | Move back one full screen |
Text Replacement & Repeat
Shortcut | Summary | Description |
---|---|---|
r | Replace char | Replace character under the cursor |
:s/foo/bar/g | Replace | Replace 'foo' with 'bar' in the current line |
:%s/foo/bar/g | Replace all | Replace 'foo' with 'bar' in the entire file |
. | Repeat | Repeat the last command |
Settings & Display
Shortcut | Summary | Description |
---|---|---|
J | Join lines | Join the current line with the next one |
>> | Indent line | Indent current line one level to the right |
<< | Unindent line | Unindent current line one level to the left |
Remaining Editing Commands
Shortcut | Summary | Description |
---|---|---|
u | Undo | Undo the last change |
<C-r> | Redo | Redo the last undone change |
S | Substitute line | Delete line and enter Insert mode |
~ | Change case | Toggle case of the character under the cursor |
<C-v> | Block visual | Enter visual block mode |
Stuff I don't really use in VS Code now
File Operations & Window Management
Shortcut | Summary | Description |
---|---|---|
:w | Save | Save the current file |
:q | Quit | Quit Vim (requires no unsaved changes) |
:e | Open file | Edit a file in a new buffer |
:tabnew | New tab | Open a file in a new tab |
:sp | Split window | Split the window horizontally |
:vsp | Vertical split | Split the window vertically |
Buffer Management
Shortcut | Summary | Description |
---|---|---|
:bn | Next buffer | Go to the next buffer |
:bp | Previous buffer | Go to the previous buffer |
:bd | Close buffer | Close the current buffer |
ctrl+ww | Switch windows | Switch between windows |
:wq | Save & Quit | Save changes and quit Vim |
:q! | Force quit | Quit Vim without saving changes |
Settings & Display
Shortcut | Summary | Description |
---|---|---|
:set nu | Show line numbers | Display line numbers |
:set nonu | Hide line numbers | Hide line numbers |
:noh | Remove highlight | Remove search highlighting until next search |
The Basics
Basic Cursor Movement
Shortcut | Summary | Description |
---|---|---|
h | Left | Move one character to the left |
l | Right | Move one character to the right |
j | Down | Move one line down |
k | Up | Move one line up |
0 | Line start | Move to the start of the line |
$ | Line end | Move to the end of the line |
Word & Paragraph Navigation
Shortcut | Summary | Description |
---|---|---|
w | Next word | Move to the start of the next word |
b | Previous word | Move to the start of the previous word |
^ | First non-blank | Move to the first non-blank character of the line |
gg | Top of file | Move to the top of the file |
G | Bottom of file | Move to the bottom of the file |
} | Next paragraph | Move to the beginning of the next paragraph |
{ | Previous paragraph | Move to the beginning of the previous paragraph |