Copy and Paste inside of Vim

Mike Hartington
InstructorMike Hartington
Share this video with your friends

Social Share Links

Send Tweet

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.

[00:00] 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.

[00:27] 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.