VI & Vim copy, paste, and cut text

Source: Internet
Author: User
I often use the VI editor, but it is basically a habit of windows. I have never learned the functions of the system. Today I have encountered text copying, which is no way to solve it. Let's take a look at the solution below: references: NLP often reflects on itself. Sensitive thinkers can better and more thoroughly control yourself and the surrounding environment than ordinary people. You hate superficial and superficial things. You would rather be alone than chatting with others, but your relationship with your friends is very deep, which makes your mood harmonious and comfortable. You don't mind being alone for a long time, and rarely feel dull. For example, if I want to copy the words "myself and the surrounding environment", first move the cursor over "self", then press the V key, and then press the L key to move the cursor to the left, at this time, the text will be selected until the context word is copied by pressing the y key. Then you can press the P key somewhere to paste it in.
This means: 1. V + move the cursor to select the text. 2. y can copy selected text. 3. P can be pasted.

Copy a row: yy copies the position of the current cursor to the end of the line: Y $ copies the position of the current cursor to the beginning of the line: y ^ copies three rows: 3yy, that is, from the current cursor + the next two rows.
Cut text: After selecting the text with V, you can copy the text by Y. If you press d, the text is cut and then pasted by P.
Cut a row: dd cut the cursor position of the current row to the end of the line: d $ cut the cursor position of the current row to the beginning of the line: d ^ cut the first three lines: 3DD, that is, the current row + the next two rows are cut.

Method 1:
Place the cursor in Row 3,
Input: 2yy
Place the cursor in Row 3,
Input: P
This method is suitable for copying a small number of lines of text. Copy two rows of data under 6th rows (inclusive) and put them under 9th rows.

Method 2:
Input in Command Line Mode
6, 9 co 12
Copy the content between 6th rows and 9th rows to the end of 12th rows.

Method 3:
You can use tags to replace the number of rows that you do not want to read or copy a large number of rows.

Move the cursor to the starting line and enter Ma
Move the cursor to the end line and enter MB
Move cursor to paste line, input MC

Then: 'a, 'B co' C. Change Co to m and cut it.

To delete multiple rows, you can use: 5, 9 de
============================ Gorgeous split line ============================
Cut is also available

Use V to enter the visual mode, and D is the DELETE command (the same as the command mode ). D and then use P to paste it. P is pasted after the cursor and P is before the cursor. Note that the items deleted with X or DD should also be placed in the clipboard, which will overwrite the content of the current clipboard. ---------------------------------------------- Not sure about the same file: move the cursor to the starting line, enter the MA cursor to move to the end line, enter the MB cursor to move to the paste line, enter MC and then: 'a, 'B co' C. Change Co to m to cut multiple files: In File 1: move the cursor to the starting line, enter Ma, move the cursor to the end line, enter MB, and then: 'a, 'B W filename in file 2: move the cursor to the row to be assigned a value, input: R filename

In command mode: move the cursor to the fifth line. Input: 6yy move the cursor to the second line. Input: P

I don't know, right?

-------------------------------------------------


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.