Vim Operation notes

Source: Internet
Author: User

1. Switch to the next file

Suppose the file you want to switch to is named test.py

: Ex test.py  


2. In-document copy command

  1. Yy"The line where the cursor is copied.  or uppercase one Y. 2yy"duplicate two lines. y^"Copy to the beginning of the line, or y0.  Does not contain the character where the cursor is located. y$"Copy to end of line. Contains the character where the cursor is located. (Note the difference with y^)yw"Copy a word (word). y2w"copy two words (words). YG"Copy to the end of the file. y1g"copy to the top of the file. P"lowercase p, attached to the cursor (bottom). P"uppercase P, affixed to the front (top) of the cursor. Enter U to undo the previous step, CTRL +R can restore the undo of the previous step there is a good way to use the line number like to put 2-5 lines cut to 12 lines at a direct:2,5Move A


3. Inter-document Copy command

Need to copy to pasteboard a

The command in 2nd is appended with a double quotation mark and A, for example:

    1. "Ayy" Copy a row
      "a3yy " copy 3 lines "ap " pasted to the cursor (bottom)

4. Cancel Highlight Search

After using the find, want to cancel the highlight, I generally use two methods:

Use the command:

    1. : Noh  

or search for a string that doesn't exist.

5. Commonly used folding commands

    1. " collapse from cursor to 12 rows   ZD "      " manual"" marker "is valid  

6. Write code with VIM

VIM is a great editor for writing code because some of its features are designed specifically for programmers. Here are some of the commonly used:
]p: Similar to the function of P, but it automatically adjusts the indentation of the pasted text to fit the position of the current code. Try it! %: Match curly braces, brackets, brackets, and so on. At the top of a bracket, and then by%, the mouse appears in the other half of the matching brackets. >>: Indent All selected codes <<: Similar to above, but indent GD: reaches the definition of the function or variable where the cursor is located. K: In man, look for the word where the cursor is currently located. 

Vim Operation notes

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.