Usually, Vim’s linguistic commands operate on a context inferred from the position of the cursor. But sometimes you may want to provide additional context for the operation. E.g. not this word but these words. Vim allows you to do this via quantifiers or “counts.”
d2w
= delete two wordsd3b
= delete the three preceding wordsc2}
= change two paragraphsc2t.
= change un(t)il the second period [we’ll learn more about t
soon]3j
= go down three lines
You can supply the quantifier either before or after the verb. E.g. 2ct.
also works. That is, verb-quantifier-noun
and quantifier-verb-noun
are essentially equivalent.
Note that going into insert mode and back into normal mode is treated as a single command in Vim. So you can also do:
20ianybody there? [hit Esc]
10i<item></item>[hit Enter][hit Esc]
✨ Bonus: Replace mode ✨
R
takes you into replace mode — it’s a quicker option in cases where you want to replace part of a word with something else of the same length. Try it!
Sérgio Araújo
A good discover comes when you do at least a visual block sekection (yank change or delete)
move your cursor to somewhere else and press 1v
sid
That’s very cool! Looks like you can even do `2v` and `3v` to scale up the block size.