Step 5 of 7

6. Copying And Pasting

Named registers

In Vim, registers are denoted with a quote — for example, the default register is denoted "", and the ‘a’ register "a.

Vim has 26 so-called “named registers” — one for each letter in the alphabet. What this means is that Vim essentially has 26 separate clipboards that you can use to store whatever you want. It is completely up to you to decide how to use them!

This is vastly superior to other editors, which typically don’t have any registers, and force you to rely on the system clipboard instead.

To access a register — say the "a register — you just type "a before a command. For example, "ayy will yank the current line under the cursor to the "a register, and "ap will put the contents of the "a register into the file.

For completeness, typing just yy is the exact same as typing ""yy to yank into the unnamed register.

Work through the checklist below.

  1. Yank the first line into the "a register With the cursor on the COPY ME INTO THE "a REGISTER line, type "ayy.
  2. Yank the next line into "b Move down a line and type "byy.
  3. Yank the next line into "c Same again, one line down — type "cyy.
  4. Yank the last line into "d And once more — "dyy.
  5. Put the lines back in a different order Below the vv marker — "bp, "dp, "ap, "cp, or your own shuffle — put your four registers back in any order you like.
Yank the first line into the "a register With the cursor on the COPY ME INTO THE "a REGISTER line, type "ayy.

Next: Yank the next line into "b

Loading editor…