Be productive with Vim – Part 4: Editing
In this article, we continue our Vim series with basic editing commands like copy, paste, cut, and undo.

Editorial translation by Impulso.
Heeey, Vim fan! Ready to talk about editing in Vim?
In the last installment, we covered some of the basics of deleting text in Vim. If you missed it, click here to see what you missed.
This time, our goal is to talk a bit about editing, specifically cutting, copying, and pasting.
Usage
Paste
I didn't mention this in the previous article, but the delete commands cut text that you can then paste with the P command. If it helps you remember, think of the letter ‘p’ as standing for “paste.” The Shift + P command also pastes, but this time it puts the text before the cursor instead of after it.
So if you use the X command to “delete” a letter, for example, you can paste it with one of the ‘p’ commands we just covered. The same goes for any of the other commands from the previous article. Deleting a word or line also makes it available to paste. So we can say that the commands we covered in our last article are editing commands too.
Copy (Yank)
In Vim, you copy text with the Y command. For example, if you want to copy the next two words, you can use the Y + 2 + W command. Naturally, you can paste that text the same way.
Following the same logic, if you need to copy an entire line, you can use the Y + Y command. It's worth pointing out that Vim has its own register system, so the text you copy will only be available in Vim's internal registers and won't show up on the system clipboard. The only register that's actually linked to the system clipboard is +. We'll talk a bit more about these registers later, but for now you can view Vim's registers by entering:reg in command-line mode.
This shows you the current registers in Vim. You can access and use them by typing " followed by the register number. For example, " + 0 + P pastes the contents of register 0, and you can use it as many times as you like.
You can also create custom registers, called named registers. You can use the letters of the alphabet as register names. For example, " + J + Y + Y copies the current line and stores it in register ‘j’. The same idea applies when pasting. To paste that text, you can do something like " + J + P.
Copying new text overwrites what's already in the register, but you can also append to a register by holding down ‘Shift’ to use the uppercase letter. For example, " + Shift + J + Y + Y copies the line and adds it to whatever was already in register ‘j’.
Just as:reg shows all the registers, you can view a specific register by telling Vim which one you want to see.:reg j shows only the contents of register ‘j’.:reg fj shows the contents of registers ‘f’ and ‘j’, respectively.
Undo
Like most editors, Vim also lets you undo and redo actions. As you've probably guessed, you undo with the U key.
To redo, use the rather “complicated” command Ctrl + R. This “enormous” command redoes the last action and is the opposite of undo U. The letter R also does something on its own, which we'll cover later.
Wrapping up
That's all for this one, folks. In the next installment, we'll talk a bit about searching, a few ways to enter INSERT mode, REPLACE mode (that's where the letter R comes in), automating case changes, and repeating commands with the count operator. It'll be fun and interesting, and we'll have plenty to talk about. You could say we're about to move beyond the basics of Vim.
See you soon, folks!!


