⭐ An IDE on top of Vim? Easy with "Vim From Scratch" book

How to copy and paste a line in Vim?

Published almost 2 years ago.

One of the most common task that beginners struggle to do in Vim is copying and pasting a line.

In reality though, it is very simple.

Type "yy" to copy a line, then "p" to paste it into the other place.

Now if you have some time, let's take a closer look at what's happening there. To copy a line,

  1. Make sure you're in the normal mode. Press Esc to be sure. Then copy the entire line by pressing yy (more info :help yy). Y stands for "yank". Instead, you can also press Y (shift + y) but I find the former a bit more convenient.
  2. Paste the line by pressing p. That will put the yanked line right under your cursor (on the next line). You can also paste before your current line by pressing the capital letter P. Again, to get some help you can use :help p.

Hopefully that was helpful.

If you are serious about using Vim in your workflow, make sure to get familiar with the most popular plugins around there.

Have a productive day!

Vim From Scratch

Learn Vim and upgrade your productivity to the next level by building an IDE of your dreams.