I usually need to move/copy code snippets between my source files. After I paste a block of text, I usually need to apply some operation to that block such as reindenting them with =.

Is there a way to easily visually select the block of text I just pasted without doing it manually?

3 Answers 3


The '[ and '] marks delimit the first and last line of the previously changed or yanked text. The `[ and `] counterparts delimit the respective lines & columns.

Using that, you could visually select the last changed block of lines with '[V'] and then apply the = command.

However, since a paste leaves your cursor at the first line of the content that was pasted, you could also just specify a motion over which the = command should be applied, in this case to the '] mark. This would be ='].


This mapping allows you to reselect the text you just pasted:

nnoremap gV `[v`]

But you should have used [p and ]p instead.

See :help [p.

  • 3
    +1 for [p and ]p
    – lisowski.r
    Commented Feb 3, 2015 at 18:33

Vim includes the following helpful mappings:




Which select the first and last character of previously changed text, respectively.

The following series of keys (in normal mode) will select the last pasted text:


For faster access, you could set up a mapping, for example:

nnoremap gp `[v`]

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.