How to Copy, Cut, Paste in Vim or Vi

Copy, Cut, Paste in Vim

Vim is one of the popular text editors among the software developers and system administrators. On the macOS as well as on different Linux Distros it comes preinstalled. When you work with Vim copy paste or cut pasting text is one of the common tasks we do most of the time. In this tutorial, you are going to learn how to Copy, Cut, Paste in Vim or Vi.

Copy, Cut, Paste in Visual Mode

If you are in any other mode press Esc to come in Normal Mode so you can run Vim commands and navigate through the file.

Place the cursor at the line where you want to start copying or cutting.

Here you can press v (lowercase) to start copy from the position where the cursor located or press V (uppercase) to copy full line where cursor located.

Now use h, j, k, l keys to move the cursor left, down, up, right where the end of text located.

Here you can press y to copy text or press d to cut text.

Then place the cursor where you want to paste the text.

Finally, press p (lowercase) to paste the text after cursor position and press P (uppercase) to paste the text before the cursor position.

You can do Copy-Paste or Cut Paste operations by using the above instructions. If you want to learn more short commands for copying to cutting text then read below points.

Copying or Yanking in Vim

The process of copying also known as yanking in Vim. To copy the text you can also use the following commands directly in Normal Mode.