Copying in vi is known as "yanking". Knowing this will make it easier for you to remember the Copy command.
To copy (yank) just a single line (the line you are currently on), hit the lowercase y key twice. For example, yy
To copy (yank) multiple lines beginning with the line your cursor is currently positioned on, enter the number of lines you want to copy followed by an uppercase letter Y. So, to copy ten lines you would enter 10Y.
Now you've got one or more lines copied into vi's buffer. Where do you want to paste them?
To Paste, Place, or Put (notice the P's) the copied line(s) somewhere in the file, you will use either the lowercase or uppercase letter P.
First, position your cursor on a line in your file. If you type a lowercase p command, the line or lines will be pasted below the current line. If you type an uppercase P command, the line or lines will be pasted ABOVE the current line.
The squiggle, or tilda, is magic. If a character is currently lowercase, the squiggle will change it to uppercase. If the character under your cursor is currently uppercase, then hitting the squiggle will convert it to lowercase.
You can get kind of crazy and have some fun with this by repeating the Change Case (squiggle/tilda) command a number of times. Remember, most commands can be repeated by typing a number before the command. So, 10000~ would toggle the case of the next ten thousand characters.
DBI is offering a free educational webinar "TEN SQL Snapshots you MUST run TODAY" on Friday, 21 January, 2pm Central (3pm Eastern, 1pm Mountain, 12pm Pacific, 8pm GMT). Attendees will receive the SOURCE CODE for the SQL Snapshots! For details and the registration link to this free event, visit DBI's EVENTS page.
Contact DBI and find out how our DB2 LUW Performance Solutions can truly help you optimize performance and lower IT costs.
To all of you, I wish everyone a safe, happy, and prosperous 2011!
Cheers, Scott