Basic Linux Tutorial
Computer Tutorial

Cut, Copy and Paste



Cut, Copy and Paste

The dd and dw commands cut the text and put it on a cut buffer. Text from the cut buffer can be pasted anyplace using the p command. The text that you want to copy from one place and paste at another is yanked (copied) first. We use the yy command to yank one line of text. You can also yank multiple lines of text by using the nyy command where n is the number of lines starting from the current cursor position. To paste the text at a new place in the file, move the cursor to that place and use the p command to place the text after the cursor position. You can also use the P command to paste the text before the cursor position.
The cut-paste combination is the same as moving text from one place to another. You can move text with the m command. The m command moves one line of text from the current cursor position to a new position given to m.

Cut, Copy, and Paste Commands

Command Effect
yy Copy or yank current line
nyy Copy n lines starting from current line position
p Paste yanked text after the current cursor position
P Paste yanked text before the current cursor position
:m a Move current line and paste after line number a
:a,bmc Move lines from a to b and paste after line number c
:a,btc Copy lines from a to b and paste after line number c