Vimtutor Flashcards
Direction Controls
h (left), j (down), k (up), l (right)
Delete any character under the cursor
x
Insert text
i
Append text
a
Delete word
dw
Delete to the end of a line
d$
Delete operator
d
Delete motions
w - start of the next word excluding the first character
e - to the end of the current word including the last character
$ - to the end of the line including the last character
Moving through a line
nw - n words forward
ne - to move the cursor to the end of the nth word forward
0 - moves to the start of the line
Delete an entire line
dd
Undo last command
u
Redo last command
CTRL-r
Put command
After deleting, press p to paste
Replace
r and then whatever letter you want to replace it with
Change
c
ce - until the end of a word
Show location and file status
CTRL-g
Move to bottom of file
G
Move to top of file
gg
Move to a specific line in a file
<number>G
</number>
Searching for a phrase
/phrase
Search for a phrase again
n
Search for the same phrase in the opposite direction
N
Searching backwards
?phrase
Go back where you came from
CTRL-o
Go forward in a search
CRTL-i
Find a matching parentheses
% when on one
Substitute new for old
:s/new/old/g
Change every occurrence of a character string between two lines
:#,#s/old/new/g
where #,# are the line numbers of the range of lines where the substitution is to be done.
Change every occurrence in the whole file
:%s/old/new/g
Execute an external shell method
:!<method></method>
Save the changes to a new file
:w FILENAME
Visual selection
v
Insert the contents of a file
:r FILENAME
Insert a line below
o
Insert a line above
O
Replace more than one character
R
Copy text
y
Paste text
p
Set ignore case
:set ic
Set hlsearch
:set hls
Set incsearch
:set is
Ignore case for one search command
/phrase\c
Show list of matching commands
CTRL-d
Command line completion
Tab