Tip 63Paste from a Register

The Normal mode put command can behave differently, depending on the nature of the text that is being inserted. It can be helpful to adopt different strategies, depending on whether we’re pasting a line-wise or a character-wise region of text.

In Tip 60, we saw that we could transpose the order of two characters by pressing xp, while ddp would transpose the order of two lines. We use the p command in both cases, but the outcome is subtly different.

The p command puts the text from a register after the cursor position (p). As a complement, Vim also provides the (uppercase) P command, which inserts text before the cursor position. What is meant by before or after the cursor position can differ, depending on the ...

Get Practical Vim, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.