Command |
Description |
vi file |
Open your file in |
:w |
Write your changes to the file |
:q! |
Quit without saving your changes |
:wq , ZZ |
Write your changes and exit |
:saveas ~/some/path/ |
Save your file to that location |
Command |
Description |
/pattern , ?pattern |
Search for string |
t |
Jump up to a character |
f |
Jump onto a character |
* |
Search for other instances of the word under your cursor |
n |
Go to the next instance when you've searched for a string |
N |
Go to the previous instance when you've searched for a string |
; |
Go to the next instance when you've jumped to a character |
, |
Go to the previous instance when you've jumped to a character |
Command |
Description |
j |
Move down one line |
k |
Move up one line |
h |
Move left one character |
l |
Move right one character |
Command |
Description |
0 |
Move to the beginning of the line |
$ |
Move to the end of the line |
^ |
Move to the first non-blank character in the line |
t<one> |
Jump to right before the next tag |
f<one> |
Jump and land on the next tag |
Command |
Description |
w |
Move forward one word |
W |
Move forward one big word |
b |
Move back one word |
B |
Move back one big word |
e |
Move to the end of your word |
Moving by sentence or paragraph
Command |
Description |
) , ( |
Move forward one sentence |
} , { |
Move forward one paragraph |
Command |
Description |
H |
Move to the top of the screen |
M |
Move to the middle of the screen |
L |
Move to the bottom of the screen |
gg |
Go to the top of the file |
G |
Go to the bottom of the file |
^U |
Move up half a screen |
^D |
Move down half a screen |
^F |
Page down |
^B |
Page up |
:$lineNumber |
Move to a given line number |
^E |
Scroll up one line |
^Y |
Scroll down one line |
Command |
Description |
i |
Insert before the cursor |
I |
Insert at the beginning of the line |
a |
Append after the cursor |
A |
Append at the end of the line |
o |
Open a new line below the current one |
O |
Open a new line above the current one |
r |
Replace the one character under your cursor |
R |
Replace the character under your cursor, but just keep typing afterwards |
cm |
Change whatever you define as a movement, e.g. a word, or a sentence, or a paragraph. |
C |
Change the current line from where you're at |
ct? |
Change change up to the question mark |
s |
Substitute from where you are to the next command (noun) |
S |
Substitute the entire current line |
Command |
Description |
u |
Undo your last action |
Command |
Description |
Ctrl+r , Cmd+r |
Redo the last action |
Command |
Description |
. |
Repeat the last action |
Command |
Description |
x |
Exterminate (delete) the character under the cursor |
X |
Exterminate (delete) the character before the cursor |
dm |
Delete whatever you define as a movement, e.g. a word, or a sentence, or a paragraph. |
dd |
Delete the current line |
dt. |
Delete delete from where you are to the period |
D |
Delete to the end of the line |
J |
Join the current line with the next one (delete what's between) |
Command |
Description |
y |
Yank (copy) from where you are to the next command (noun) |
yy |
A shortcut for copying the current line |
p |
Paste the copied (or deleted) text after the current cursor position |
P |
Paste the copied (or deleted) text before the current cursor position |
Learn vim For the Last Time: A Tutorial and Primer
OpenVim
Vim adventures
Vim genius
Vim Valley
Vim-Go