How to automatically remove newline at end of yanked linewise visual selection?

Viewed 889

Is there any way to yank a linewise visual selection without the newline at the end of the last line of the selection? More specifically, I'd like to be able to copy a line or lines from vim to the system clipboard and paste it elsewhere without the last command being executed without a chance to edit it.

I can get the desired effect by executing this command on the register in question after yanking:

:let @*=substitute(@*,'\n$','','g')

but is there any way to execute that command automatically? I am using MacVim at the moment and there doesn't appear to be a way to map an extra command to ⌘-C, so I'd have to have another mapping to remember to execute after copying if I can't find another solution.

2 Answers
Related