COPY and PASTE
I know you really didn't want to retype all your work simply to replicate a masterpiece. While you are in COMMAND Mode (hit the ESC key), position your cursor at the beginning of the line (or lines) that you want to COPY.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.
CHANGING CASE
While in command mode, position your cursor over any alphabetic character in your file and hit the squiggly key (most people call it the tilda character). The ~ is usually located under ESC on most keyboards and you'll probably have to hit SHIFT to access the squiggle.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.
OOOOOPS, I DIDN'T MEAN THAT
Did you make a mistake? Don't like the results of the last command you typed? The lowercase u command will Undo the last command entered.
Summary
Between Parts 1 and 2 of this quick vi editor tutorial, you no longer need to fear the UNIX or Linux world if you are coming from DB2 z/OS or Windows. And, welcome to the "Open Systems" world. Glad to have you here.Our Shameless Marketing Moment
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.
Our #2 Job is giving you the documentation to prove it!
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