Skip to main content
edited tags
Link
Rich
  • 32.6k
  • 4
  • 74
  • 141
replaced http://vi.stackexchange.com/ with https://vi.stackexchange.com/
Source Link

N.B. This is not a duplicate of How does the "d3fg" command work?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 onesquest 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 3j motion,

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 d[count]d mapping?

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 deleting, :help motion.txt, and tried :helpgrep dNd for all values of N from 1–9.

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 3j motion,

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 d[count]d mapping?

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 deleting, :help motion.txt, and tried :helpgrep dNd for all values of N from 1–9.

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 3j motion,

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 d[count]d mapping?

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 deleting, :help motion.txt, and tried :helpgrep dNd for all values of N from 1–9.

edited tags
Link
Rich
  • 32.6k
  • 4
  • 74
  • 141
edited tags
Link
Martin Tournoij
  • 63.3k
  • 26
  • 199
  • 274
Loading
Add speculation about possible answer, and renamed to match what I'm actually trying to achieve
Source Link
Rich
  • 32.6k
  • 4
  • 74
  • 141
Loading
edited tags
Link
Rich
  • 32.6k
  • 4
  • 74
  • 141
Loading
Source Link
Rich
  • 32.6k
  • 4
  • 74
  • 141
Loading