vi/vim editor, copy a block (not usual action)

Yang picture Yang · Nov 19, 2012 · Viewed 261.1k times · Source

In vi/vim editor, I need to copy a block. There are many ways, but one way is very quick.

  1. label the first line by some way,

  2. then label the end line by some way,

  3. then put some command to copy the labeled lines.

  4. then copy, may using 'p', but not sure.

Anybody know the commands (not yy or 10yy)? Thanks in advance.

Answer

André Keller picture André Keller · Nov 19, 2012

just use V to select lines or v to select chars or Ctrlv to select a block.

When the selection spans the area you'd like to copy just hit y and use p to paste it anywhere you like...