Vim Basics

How to paste in vim

We'll go over a few ways that you can paste in vim. First we have to talk a bit about registers. Registers are pieces of memory that vim uses to store text. They allow you to copy, cut, and paste in vim. There is a lot to know about registers but for now we'll just focus on the basics.

  • 1. The default register is ". This is where text is copy or pasted from if you don't specify a particular register.
  • 2. There are named registers that go from a to z. You can store text in a specific register to retrieve later. (i.e. store some text in register a and then paste it later by pressing "ap)
  • 3. The system clipboard register is *. This is where your clipboard contents are stored if you do the typical right-click copy or CMD+C outside of vim.

Paste system clipboard while in normal mode"*p

While in normal mode, to paste your system clipboard contents into vim press "*p.

How it works:

  • esc – Enters normal mode
  • " – While in normal mode, if you're pasting from a particular register you need to prefix it with this symbol.
  • * – this register stores the contents of the system clipboard
  • p – this stands for put, which pastes the text from the given register into the text file.

This wasn't an exhaustive list but it should cover you for most pasting needs in vim!

Learning vim can be challenging but if you stick with it, you'll be flying through your code in no time. Learning enough to get comfortable and productive is the most important part. Once you're comfortable, you can start learning more advanced features.

If you're looking to get comfortable with vim quickly, check out our concise interactive course! We've helped over 2000 engineers learn to love vim!

Check it out