Vim End-Of-Line Inconsistency?

7 views
Skip to first unread message

aditya siram

unread,
Jun 17, 2015, 8:35:58 AM6/17/15
to vim-...@googlegroups.com
Just noticed something that seems inconsistent with motions and using the '$' to go to the end of a line. Given the line:

a b c d e

if point is on 'a' and I do 'd$' to delete to the end of the line, it yanks 'a b c d e', however if I visually select and then delete 'v$d' it yanks 'a b c d e\n' which includes the newline at the end. I have similar issues with 'y$' and 'v$y'.

Thanks!
-deech

Cryptic Swarm

unread,
Jun 17, 2015, 9:55:54 AM6/17/15
to vim-geeks
For visual mode you can do 'vg_d' to delete not including \n.

For normal mode you can use 'D' instead of 'd$'  to delete to end of line not including \n.



--
You received this message because you are subscribed to the Google Groups "Vim Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim-geeks+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

aditya siram

unread,
Jun 17, 2015, 10:30:39 AM6/17/15
to vim-...@googlegroups.com
Neat tip about 'D'!
I never figured that out because '_' goes to the first non-blank. Never occured to me that 'g_' goes to the last one.

The behaviour of 'd$' and 'v$d' still seems inconsistent though. :)

Thanks!
-deech

Cryptic Swarm

unread,
Jun 17, 2015, 10:49:25 AM6/17/15
to vim-geeks
Yeah, that is pretty inconsistent. I've tried figuring out why it did that before. I had thought it was something to do with the virtualedit settings I use, but wasn't able to get it to work the same.

Another inconsistency is that 'D' deletes to end of line but 'Y' does not yank to end of line, but that can be remedied with 'noremap Y yg_'.

Michele Berg

unread,
Jun 17, 2015, 10:59:33 AM6/17/15
to vim-...@googlegroups.com
Thanks for the tip about 'D' - I use d$ every day.  Nice to have another tool in my toolbelt.

Michele
Reply all
Reply to author
Forward
0 new messages