This is related to better copy-paste multiple lines in visual mode where vim pastes after that visual chunk of code.

I need to be able to detect which way vim is going into visual mode so that I can use the following workflow:

  • Select multiple lines
  • Press Ctrl+l to copy-paste entire block after (not inside the first selected block) with cursor at the beginning of 2nd paste

Here are some mappings that do one direction but not both:

" up to down
vmap <c-l> ygv<Esc>p

" down to up
vmap <c-l> ygvo<Esc>p

1 Answer 1


You can always use the '> mark, which always selects the last line of the last Visual selection, regardless of having been selected from top to bottom or from bottom to top.

So one possible solution to your mapping is:

xnoremap <c-l> y'>p

(It looks like from the other post you got ygP which is slightly better, as it's shorter and it's avoiding a jump movement with '>.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.