Beware of case (upper and lower case), the commands will not do the same thing between upper and lower case!
Command | Comment |
---|---|
:w | Save file |
:x or :wq | Save and Exit |
:q | Exit if no change has been made |
:q! | Exit and undo changes |
:set nu | Display line numbers |
:r file | Import a file into the current file |
:nr file | Import a file into the current file from the n line. |
Command | Comment |
---|---|
x | Delete a single character (the one on which the cursor is positioned). |
X | Delete the character behind the cursor |
D | Delete the rest of the line from the cursor. |
dd | Delete an entire row |
ndw | Delete next n words |
ndd | Delete the next n lines |
:x,yd | Delete from line x to line y |
Command | Comment |
---|---|
i | Insert on cursor |
a | Insert after the cursor |
I | Insert on the following line |
A | Insert on previous line |
o | Insert a new line after the current line |
O | Insert a line before the current line |
ESC | Exit insert mode |
Command | Comment |
---|---|
p | Paste the contents of the clipboard over the line. |
P | Paste the contents of the clipboard over the line. |
yy | Copy a line |
yw | Copy a word |
y$ | Copy from the cursor position to the end of the line. |
Command | Comment |
---|---|
/desired word | Find the desired word after the cursor position |
?desired word | Search for the desired word before the cursor position. |
n | Find the next occurrence of the desired word. |
N | Find the previous occurence |
:%s/old word/new word/g | Replace all occurrences of the old word with the new word. |
Command | Comment |
---|---|
h | Move 1 character to the left |
j | Move 1 character down |
k | Move 1 character up |
l | Move 1 character to the right |
w | Move on to the next word |
b | Move to the beginning of the word |
e | Move to the end of the word |
( | Move to the beginning of a sentence... |
) | Moving to the end of a sentence |
{ | Move to the previous paragraph |
} | Move to the next paragraph |
^ | Move to the beginning of the line |
$ | Move to the end of the line. |
<n>G | Move to the nth line. |
G | Move to the last line |
gg | Move to the first line |
% | Move to the corresponding parenthesis |