This is related to/a continuation of How do I replace-paste yanked text in vim without yanking the deleted lines?
vnoremap p "_dP is used to paste over visually selected text without overwriting the
"* register with the replaced text. That way, subsequent visually-selected pastes are kept the same.
That remap works as expected except when a characterwise visual selection goes to the end of the line. I'm trying to figure out a way to handle this conditionally, so that:
- in that specific case, do
- otherwise, do
I'm thinking of
vnoremap p to a vimscript function that checks for that specific case, i.e. "if visual selection is characterwise and cursor is at the end of the line", and execute accordingly.
meta - if vimscript is the answer, maybe I should post to StackOverflow?
It works with:
vnoremap <expr> p (getregtype() ==# 'v' && col(".") == col("$") - 1 ? '"_dp' : '"_dP')