VIM Easy Tutorial (4)

Source: Internet
Author: User
The fourth lesson basic copy, paste operation Cut and paste

When a piece of text is deleted with command D or x, the deleted text is automatically saved to a special clipboard by VIM. You can then use the P command (put) to paste it behind the cursor location.

You can try entering the following two commands in turn:

Dd

P

These two commands are executed to replace the two lines of content, similar to the following command

X

P

The position is reversed by two letters.

The P command can also be preceded by a number that indicates repeated pasting n times. add tags to the text

Sometimes, we want to delete a large block of text, directly with the D command it is difficult to describe the beginning and end of the text block. You can use the M command (Mark) to make a mark in the text. Let me give you a concrete example. For example, have the following text:

int main (void)

{

Double x = 1e-2;

Double y[5];

Y[0] = gsl_log1p (x);

Y[1] = log1p (x);

Y[2] = LOG1P2 (x);

Y[3] = LOG1P3 (x);

Y[4] = log (1+x);

printf ("gsl_log1p =%.15e\n", y[0]);

printf ("log1p =%.15e\n", y[1]);

printf ("LOG1P2 =%.15e\n", y[2]);

printf ("LOG1P3 =%.15e\n", y[3]);

printf ("log (1+x) =%.15e\n", y[4]);

return 0;

}

You want to remove a few printf statements. First move the cursor to the first character p of the first printf statement. Executes the command MA. A is the name of the tag, and the named rule is the same as the Q command. Then move the cursor to the first character of the return statement, R. Enter Command d ' A. You can see that several lines of printf statements have been deleted.

' A ' indicates the location of the marker.

' A indicates the beginning of the line where the marker is located

When we make multiple marks in an article, we may not even remember where those tags were placed. You can then display all the tokens with the following command.

: Marks

As you can see, in addition to the tags we define, there are many more system-customized tags. Their meaning later in the introduction. Copy Command

Vim says the copy operation is yank. The corresponding command is Y.

The y command is similar to the D command, except that it does not delete the selected area.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.