Vim text editor logo image
Tech

Vim–How to Cut, Copy & Paste Text

Copy & Paste:

Select/Highlight:

First to select the characters use ‘v’ to enter ‘VISUAL’ mode. (Hit ‘v’ again to go back to “normal” mode.) We can select (highlight) one character at a time by hitting the cursor left or right. We can also hit up or down to select the current line and the next line up to the character column that we are spaced at.

Shift-‘v’ or Uppercase ‘V’ enters ‘VISUAL LINE’ mode. (Hit shift-v again to go back to “normal” mode.) This will select the entire current line. We can then move up or down to select (or deselect), by highlighting, the lines we want.

Control-‘v’ enters the ‘VISUAL BLOCK’ mode. (Hit control-v again to go back to “normal” mode.)

The best way of learning this and getting used to it while having fun is to open and dummy/test file and just start playing and experimenting with what happens. We can always ‘Google’ to find out exactly what a command does if you’re unsure about pressing it first (usually always recommended).

Copy:

In VISUAL mode hit ‘y’ to yank (copy) the selected characters.

Hit ‘x’ to cut the selected characters.

Paste:

Hit ‘p’ or ‘P’ to paste the cut/copied characters.

Links:

VIM User Manual: http://vimdoc.sourceforge.net/htmldoc/usr_toc.html