Since vim doesn’t support native clipboard on OS X by default, I decided to create some keybindings to emulate it.
I started with such a command, which passes visual selection to pbcopy and replaces selection with command output. Since it has no output and just deletes text, i immediately undo the change.
:vmap c !pbcopy<CR> :undo<CR>
It works fine, but not if I’m copying the last line in the file. It is copied well, but undo doesn’t bring it back. If I manually undo later, it works fine.
Is there a way to make this binding work with on the last line as well?
Remove the space between the first
<CR>and:undo: