2

v^ and v_ both select to the first non-blank character on the line.

d^ deletes to the first non-blank character on the line, but d_ deletes the entire line.

Why is this? Is there any reason to use it over dd?

1 Answer 1

5

_ is a linewise motion operator (:h linewise), its primary purpose is to move your cursor to <count> - 1 lines below your current position.

For example:
5_ will move your cursor 4 lines down

The motion to the beginning of the line is just a side effect of that move. So when you type d_, the delete operation is applied from the current line to 0 lines below the current line. Result is, the current line gets deleted.

^ is a characterwise motion operator (:h characterwise), that's why it doesn't delete the whole line.

In that case, since the visual mode doesn't change the text, you don't see the linewise / characterwise difference.

I don't think d_ has any difference with dd in terms of performances or behavior, you can use one or the other.

1
  • 2
    _ is mostly there for operators that dont provide the “hit twice for a line”—handy in custom maps/operators Commented Mar 11, 2020 at 22:07

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.