Vim Common commands

Source: Internet
Author: User

Method 2:
Input in command line mode
6,9 Co 12
Copy the contents of lines 6th through 9th to the following line 12th.
Method 3:
Sometimes you don't want to struggle to see how many rows or large lines are copied, you can use labels instead
Move the cursor to the start line, enter the MA
Move the cursor to the end line, enter MB
Move the cursor to the pasted row, enter the MC
Then: ' A, ' B Co ' c changes the co into m and cuts it.
To delete multiple lines, you can use: 5, 9 de

GG       to top G        to end of page
Line number +g   jumps to the specified line n+       the cursor moves down n rows N-       cursor up n rows ctrl+g   query current line information and current file information

Search and Replace commands
/pattern: Searches for pattern at the end of the file from the beginning of the cursor
? pattern: Searches for pattern from the beginning of the cursor to the top of the file
N: Repeat the last search command in the same direction
N: Repeats the last search command in the opposite direction
: s/p1/p2/g: Replaces all P1 in the current row with P2
: n1,n2s/p1/p2/g: All P1 in line N1 to N2 are replaced with P2
: g/p1/s//p2/g: Replace all P1 in the file with P2

----5. Edit 2 files Simultaneously, copy the text from one file and paste it into another file.
----VI file1 file2
----YY in the cursor at the file 1 copy the row
----: n Switch to File 2 (n=next)
----p Pastes the copied row at the cursor where the file 2 is located
----: n Switch back to file 1

Vim Common commands

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.