Copy and Paste inside of Vim

Mike Hartington
InstructorMike Hartington
Share this video with your friends

Social Share Links

Send Tweet
Published 8 years ago
Updated 4 years ago

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.

egghead
egghead
~ 24 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today