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?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.Sign up to join this community
_ is a linewise motion operator (
:h linewise), its primary purpose is to move your cursor to
<count> - 1 lines below your current position.
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.