Copy from above or below

4.5
(123)

Here’s a quick tip that I often forget but that comes in handy now and again. While in insert mode, you can copy from the line above with <ctrl-y>. This will insert the character directly above the cursor. Or you can use <ctrl-e> to insert the character from the line below the cursor.

  • <ctrl-y> – While in insert mode, copies the character from the line above.
  • <ctrl-e> – While in insert mode, copies the character from the line below.

And you can just hold down either one to copy continuously from the line above or below. There’s a video below showing this in action.

You can see that for portions of my text entry I want exactly what is below or above. Of course, I could have used yy to yank the line and p to paste in order to duplicate and then edit. But maybe I forgot, or maybe the line was mostly different and it was easier to start from scratch. Either way, I can just tap <ctrl-y> to copy from above or <ctrl-e> to copy from below.

How useful was this tip?

Average rating 4.5 / 5. Vote count: 123

No votes so far! Be the first to rate this tip.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Written by

Colin Bartlett

105 Posts

Vim enthusiast and software developer for more than 20 years.
View all posts