If you are just starting out with vim, this post will make learning vim so much easier.
(I made a video on this topic here)
Some basic things
Vim has operators, a few are:
y
- (y)ank (copy) textc
- (c)hange textd
- (d)elete text
Vim has motions:
w
- Move forward a (w)ordb
- Move (b)ack a word{ }
- Next paragraph/previous paragraph
Combining them all with numbers
If we press 2w
vim will jump forward 2 words.
if we press c2w
vim will change 2 words.
c2w
is Change 2 Words, it's english, same as;
d5w
- Delete 5 words.
Advanced
dtl
- Delete to l
t
here is actually another movement, till so to go (t)ill the l just type tl
1
ciw
change in a word. This will change a whole word even if your cursor is in
the middle of it
dat
- delete around tags (html tags for example)
Even though I have only shown a few examples you can endlessesly combine these,
for example we know that dat
deletes everthing around a html tag but we can
do yat
to copy the tag or cit
to change in the tag. or y}
to yank the
next paragraph.
Vim is just english. If you know the basic operators and movements you can endlessly combine them. Don't memorise them, memorise the meaning, not the actual chracter.
This way you can endlessly combine them and know more commands then you can think off.
-
I prefer to call
t
to, not till - but it's called till ↩