h j k l |
cursor move either the arrow or
hjkl keys |
vim FILENAME <ENTER> |
To start Vim from shell
|
<ESC> :q! <ENTER> |
to trash all changes.
to save the changes. |
x |
To delete the character at the cursor
|
i |
INSERT MODE before the cursor
|
A |
INSERT MODE after the line
|
dw |
del from the cursor to the next word
|
d$ |
del from the cursor to the end of line
|
dd |
del whole line
|
2w |
repeat the motion with a number
|
operator [number] motion |
where:
- is what to do d - [optional] repeat motion 2 - move to the text to operate 2w |
0 |
move to the start of the line
|
u |
To undo previus action
To undo all the actions on a line To undo the undo's |
p |
put the deleted text AFTER the cursor
|
r [char] |
replace the character under the cursor
|
c |
change from the cursor where the motion take you. Eg.
c$ ce cw |
c [number] motion |
it is the format for changing
|
CTRL-G |
show your location and the file status
move to the end of the file move to that line number go to the first line |
/foo <ENTER> |
search
foo FORWARD of the phrase search foo BACKWARD of the phrase find the next occurrence find the previous occurrence Takes you to the PREVIOUS position Takes you to the NEWER position |
% |
type it on
( , ) , [ , ] , { or } and goes to its match |
:s/old/new |
substitude first
old for new substitude all old for ǹew in the linesubstitude all matchs between the lines # substitude all matchs in the file to check each time add c |
:!command |
execute an external
command Eg. win: !dir or in Unix: !ls |
:w FILENAME |
write the current VIM file to the disk with the name
FILENAME |
v motion :w FILENAME |
saves visually selected lines in the file
FILENAME. |
:r FILENAME |
retrives disk file FILENAME and puts belong cursor position
|
:r !command |
reads the output
command and puts belong the cursor Eg. win: !dir or in Unix: !ls |
oO |
insert a line BELOW the cursor and start
INSERT MODE. Open a line ABOVE the cursor |
aA |
insert text after the cursor
insert text after the end of the line |
e |
move to the end of a word
|
y |
copy the text and
p paste it |
R |
Enter in
REPLACE MODE until <ESC> is pressed |
:set foo or ignorecase or insearch or hlsearch |
sets the option
foo Eg. :set ic ignore upper/lower case when seaching show partial matches for a search phrase highlight all matching phrases. |
:set nofoo |
preset
no to switch an option off Eg. :set noic |
<HELP KEY> |
Vim has a comprehensive on-line help system. To get started, try one of these three
|
:help cmd |
to find help on
cmd |
CTRL-W CTRL-W |
to jump to another window
|
:q |
to close help window
|
~/.vmrc |
a startup script to keep your preferred settings.
|
:cmd CTRL-d |
to see possible completions,
to autocomplete |
Thank you for making this cheatsheet, I was about to create it and you spared me some time.
Cheatography n. The art of mapping complex subjects into clear, instantly navigable reference guides.