Vim learning notes (1) -- vim operations and vim learning notes operations

Source: Internet
Author: User
Tags exit in

Vim learning notes (1) -- vim operations and vim learning notes operations

Only record some of the most commonly used vim operations and update them at any time

Text operations
  • D cut. Double-click to cut a row.
  • Copy y. Double-click to copy a row.
  • P Paste

  • X: Delete characters under the current cursor

  • R replaces the current cursor character, followed by the replacement character

  • : S/old/new/g replace old with new globally

Mobile
  • 0 to start
  • $ Move to the end
  • W moves to the beginning of the next word
  • E. Move to the end of the next word.

  • The first position after fx is moved to the row that appears with the x letter

  • The first position after tx is moved to the row that appears before the x letter

  • Gg jump to the beginning of the file

  • G to the end of the file
  • NG can be moved to line N or N.

  • {Previous paragraph,} next paragraph

  • % Jump to matching brackets

  • Ctrl + o previous position

  • Ctrl + I next location

Text movement and operations work with each other. For example, d $ + enter is deleted to the end of the row, dw is deleted to the next word, and 2dd is deleted to the next two rows.

It can also be used with numbers, such as y + enter5. Copy the following five rows: 1, 20d + enter to delete 1 ~ 20 rows

Switch insert mode
  • I enters the insert mode. The current insert cursor position is inserted.
  • A enters the insert mode, insert at the next cursor position
  • O enters the insert mode and inserts data in the next row of the current row.
  • O enters the insert mode and inserts a row on the current row

You can configure vim to move the cursor to the position mode.

Visualization Mode
  • : V enters the visualization Mode
Replacement Mode
  • : R enters the replacement mode.
Use external commands
  • :! In! Add External commands
Search
  • : // Add the content to be searched after/

When searching, press n to find the next and N to find the previous

File Operation Save File
  • : W save
  • : Saveas filename save
Exit
  • : Q
Save and exit vim

Save and exit in vim: The difference between x and: wq is as follows:
: Wq and ZZ write and exit forcibly (Save the disk and exit write % quite ). Write the file forcibly even if it is not modified, and update the modification time of the file.
: X write the file and exit. The file is written only when the file is modified, and the file modification time is updated; otherwise, the file modification time is not updated.

In general, the two are not the same, but programming may have an important impact on editing source files. Even if the file has not been modified, ": wq" forces the update of the file's modification time. This will make the compilation of the entire project think that the file has been modified, then you have to recompile the link to generate an executable file. This may cause people to misunderstand the consequences. Of course, it also produces unnecessary system resource costs.

Operation rollback and redo
  • U undo the previous Modification
  • U undo the changes made by the bank
  • Ctrl + r redo operation
Others
  • Ctrl + g display current file information
  • Ctrl + d completion command

References:

  • Vmtutor
  • Http://coolshell.cn/articles/5426.html

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.