Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Copy and Paste inside of Vim

    Mike HartingtonMike Hartington

    Sometimes you just need to copy some code from one file to another. Vim allows you to do this, in a quick and efficient way.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    As you can expect, VIM has the ability to copy and paste text from within the editor. Let's copy this sentence by hitting V to enter visual mode. With the whole sentence selected we can press Y on our keyboard to copy or yank the text. Then further down the file while in normal mode, we can press P to paste or put the copy text into the file. You can also do the same thing with VIM's delete command.

    Back at the top of the file, pressing DD to delete the entire line behaves the same as cut would in any other editor. The text is deleted but we can still paste it back. One thing to know about VIM is that copied text does not get added to the system clipboard. If we copy this sentence again and then open up a different editor, when we try to paste we won't get the text from VIM.