5.9 Cut, Copy, and Paste

   

You have already seen commands used to delete text, such as dd and dw . These 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 n yy 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 . For example, m 7 will move the current line to line number 7. You can also move multiple lines of text with the m command, for example, " 1,15m76 " will move lines 1 to 15 and paste them after line number 76.

The line number method can also be used to copy and paste text. As an example, " 7,23t55 " will copy lines 7 to 23 and will paste these lines after line number 55. To remind you, you can use the :set number command to see line numbers with each line. Table 5-7 shows commands related to cut, copy, and paste.

Table 5-7. Cut, Copy, and Paste Commands
Command Effect
yy Copy or yank current line.
n yy 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 .

   
Top


HP Certified
HP Certified: HP-UX System Administration
ISBN: 0130183741
EAN: 2147483647
Year: 2000
Pages: 390
Authors: Rafeeq Rehman

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net