What is yanking in linux




















Pressing the Esc key and entering the command yw copies the word immediately after the cursor to the default register; similarly, yy copies the line after the cursor, and dd deletes and copies the current line.

To yank or delete multiple words or lines, preface a command with the number of words or lines. For example, 2yw copies the next two words after the cursor. The only feedback that any of these command returns is a brief summary of the number of lines affected when multiple lines are involved. In much the same way, the command p pastes the latest item in the register after the cursor, and P pastes it before the cursor.

To pull another of the eight items in the register, specify its number before the command; for example, 3P pastes the third latest item in the register before the cursor. Unless you have a perfect memory, you will probably need :reg or :register to see a list of items currently in all the registers Figure 1.

In all these circumstances, the default is the first register. However, you can use another register by prefixing the command with another register's name, so that bp pulls a command from register b.

In visual mode, you can highlight a block of text by indicating its starting point with a v and its endpoint with a V. You can then yank or pull the highlighted block by using the same commands that you would when selecting text by cursor position. Even more elaborately, in visual mode [2] , you can add a marker anywhere in your text using m plus a lowercase letter. Once the marker is created, you can return to it by typing its name.

More to the point, you can highlight a text block by referring to two markers — for example, the command 'b'c highlights all text between marker b and marker c, which can then be yanked or pulled like any other highlighted block. You can also do the same thing with the current mouse position and a single marker, so that y'a highlights everything between the cursor and marker a.

YankRing is a plugin that adds to, enhances, and simplifies Vim's default yank and pull features. By analogy to an Emacs feature called the kill ring, it refers to its register as a yankring. Despite the different names, the analogies between unenhanced Vim and YankRing are generally obvious. YankRing's backward compatibility is strong.

For example, although you can still use additional registers, given that the yankring by default holds elements to default Vim's nine, you are unlikely to need them. Similarly, you can use the same commands as in unenhanced Vim, although you will probably prefer to use YankRing's own commands. You can even run YankRing with or without its visual window.

The vi editor allows you to copy text from your file into temporary buffers for use in other places in the file during your current vi work session. Each buffer acts like temporary memory, or, as some programs call it, a "clipboard" where you can temporarily store information. The simplest case would be using the vi command mode command:. The u undo command undoes the most recent thing you've done in vi. If you've deleted something by accident, the u command will restore it to your file.

Whenever you delete something from a file, vi keeps a copy in a temporary file called the general buffer. You can also delete or copy lines into temporary files called named buffers that will let you reuse those lines during your current vi work session.

This feature is particularly useful if you are editing a file that contains a lot of boilerplate text or repetitive code. When you quit vi, all the buffers are emptied; they are temporary storage that only lasts for your current vi work session. To copy text into a buffer, use the vi yank command.

The most common uses are outlined below. The vi p and P commands "put" the line back into the file just after p or just before P the line on which the cursor is resting. For example, to copy 12 consecutive lines from one part of a file to another, follow these steps:. To copy 12 consecutive lines into a buffer named f and place those lines in another part of the file later in your work session, follow these steps:.

If you use the vi dd command delete a line instead of the yy command, you can move lines to a new location. On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site.

While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson but not the third party web trend services to link information with application and system log data.

Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services. This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising.

Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure. Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider.

Marketing preferences may be changed at any time. If a user's personally identifiable information changes such as your postal address or email address , we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service informit.

Users can always make an informed choice as to whether they should proceed with certain services offered by Adobe Press. If you delete or yank any other text before putting the new text in place, the lines you yanked or deleted will be lost.

Moving lines also requires two commands: dd "delete" and either p or P. To move one line, position the cursor anywhere on the line and type dd. For example, to delete 5 lines, type 5dd. Next, move the cursor to the line above where you want the deleted line reinserted and type p.

This inserts the text on a new line below the cursor. To repeatedly insert a group of lines in various places within a document, you can yank or delete the lines into a named buffer. You specify named buffers by preceding a command with double quotes " and a name for the buffer.



0コメント

  • 1000 / 1000