Vi/vim copy and paste command

Source: Internet
Author: User

Vi/vim copy and paste command 1. Select the text block. Use v to enter the visual mode and move the selected content of the cursor key. 2. the Copy command is y, that is, yank (mentioned). The Common commands are as follows: when y selects a block in v mode, it is used to copy the selected block to the buffer zone; yy copies the entire row (nyy or yny, n rows are copied, n is a number); y ^ copies the content from the current row header; y $ copies the content from the current row to the end of the row; copy a word (nyw or ynw, copy n words, n is a number); copy yG to the end of the file (nyG or ynG, copy to the nth line, such as 1yG or y1G, copy to the end of the file) 3. the cut command is d, that is, delete, d is similar to y, so the two commands use the same, including the use of numbers. d cut the selected block to the buffer; dd cut the entire row d ^ cut to the first row d $ cut to the end of the row dw cut a word dG cut to the end of the file 4. paste the imperative p, that is, put (put down) p lowercase p stands for sticking to the cursor (bottom), because the cursor is at the position of a specific character, therefore, P is followed by this character. P indicates that the entire row is copied and pasted before the cursor. The cursor is one row up (down), and the non-whole row is copied before (after) the cursor. Note: In a regular expression, ^ indicates the starting position of the matching string, $ indicates the end position of the matched string. Add a number to the front of the command to indicate the number of repetitions, and add a letter to indicate the name of the buffer used. You can use the English period "." To repeat the previous command. During copy and paste, another group of commonly used commands are u (Undo operation), U (undo all the latest modifications of a line), Ctrl + R (redo ), these functions are mainly in vim, and there is a slight difference in vi.

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.