I know I can select pasted text using this trick mapped to gp.

That means if I paste and then want to select the pasted block, I need to say p and gp.

I want to paste and immediately select that, ideally with P.

How can I achieve that?

Will I mess anything up if I rebind P?


You can use

nnoremap P p`[v`]

Doing this you will not "mess" anything but you will loose the ability to put the text from the register before the cursor (which is what P does by default).

To avoid loosing P you could also use

nnoremap P P`[v`]
nnoremap p p`[v`]

This way you will still get the put before and after cursor behavior but you will also always select the text put.

  • Similar mapping: Select last modified text block, nnoremap gV [v] or nnoremap <expr> gV '[' . getregtype()[0] . ']' – Peter Rincker Dec 30 '17 at 1:22
  • 1
    @PeterRincker Pro tip: escape backticks inside inline code blocks with backslash to make them render properly: nnoremap gV `[v`] . Took me a while to figure this out. :) – B Layer Jan 1 '18 at 0:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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