N.B. This is not a duplicate of How does the "d3fg" command work? Please read it before voting to close!
I've come to a bit of an impasse in my quest to get small deletions work like big ones. The problem I've got is that I can't figure out how to remap commands like d3d. In fact, I can't even understand how they work in the first place, nor find any mention of them in Vim's help.*
d3j is straightforward: it applies the
d operator to the
3dd is also straightforward: it runs the
dd command with a "count" of 3.
d3d looks like it should be straightforward, it applies the
d operator to the… but what is
3d? It's not a motion. If you type 3d on its own, Vim treats it as a count followed by an operator, and waits patiently for further input.
And you can't apply operators to other operators. dd isn't described in the help as a sequence of two operators. It's a separate, two-keystroke command. (cf. dc, which does nothing.)
It also doesn't appear to be the case that the positioning of the count is flexible for commands that require two keystrokes: 2gj moves the cursor down two screen-lines, but g2j discards the first two keypresses entirely and moves the cursor down one line.
So how does it work? Is this just a special case in Vim's internal code? Is there any way I can create a
EDIT: Is it a text object?
:h text-objects doesn't include it in the list of "text object selection commands", but then it does include dd in a list of deletions "grouped from small to big objects". And d2aw does delete the word under the cursor and the following one. On the other hand, c2d does nothing.
* I'm sure some mention of them must exist, but I can't find it. I've read
:help motion.txt, and tried
:helpgrep dNd for all values of N from 1–9.