Vim (and vi before it) has a command set that is a composable language.
First, you have
motions. These are actually the nouns of the command language, but on their own they mean cursor movements. There are a whole lot of them.
h is left,
l is right,
j is down,
k is up (all one character).
$ is end of line,
^ is beginning of line,
) are beginning and end of paragraph. That’s enough for now (but there are heaps more).
Then you have verbs.
Verbs are followed by a motion to make a sentence.
d is delete.
dl is delete next character,
dh is delete previous. So now you can guess that
(d) is delete this paragraph,
d$ is delete the rest of this line… and so on.
Double a verb to apply it to the whole current line…
dd for example.
Prefix it with a number to do it that many times…
55dd deletes the next 55 lines.
So how do you actually put stuff in to a file?
ilets you insert stuff in front of the cursor (it’s an exception because it doesn’t take a motion). After you type
iyou’re in insert mode; press the
control-[to get out. Note that vim starts in view mode, you have to type a command to get in to insert mode to start typing stuff.
smeans substitute, and it will replace the motion with whatever you type.
swis substitute word, and a command I use a lot.
ssis substitute current line.
ameans append, and it’s exactly like insert except it goes the other side of the cursor.
There’s a bunch of verbs for useful things like cut and paste.
Deleteis actually cut
ppastes after the cursor
: lets you into vim’s other main mode, command mode, which has a lot of power. Something like:
:wis the save command
- You can combine them as
- Help is
So, that command set as language idea makes vim completely different from other editors in how it sits in your mind.
Original content source: , Performance Measurement Lead at Fastly (2019-present), who’ve answered it here.