Vim common skills summary 2

Source: Internet
Author: User

My main blog: half an acre of fangtang

1. Search for characters in the row where the cursor is located in Normal Modef{char}Command to move the cursor to the position where the character is located.;, Roll back to search,

2. search and replace the cursor in the row in Normal Mode:s/target/replacementThe target and replacement are replaced by the replaced character or string and the replaced character or string, respectively.&Command, used in Normal Modeu

Manually control the use of each replacement in Normal Mode:%s/target/replacement/gcIn this way, VIM will ask whether to replace each time there is a replacement, there are the following options:
y: Replace the match here
n: Ignore matching here
a: "All" -- replace all the matching values here.
l: "Last" -- replace the match and exit.
q: Exit the replacement process.
<C-e>: Scroll up the screen
<C-y>: Scroll down the screen

3. Search for words under the current cursor in Normal Mode*

4. one-click movement and one-click modification --.Paradigm

5. When writing code, please immediately go back to the normal mode and cut the thinking unit into blocks, so that you can easily make a mistake by pressinguDuring the rollback operation, you can connect to the previous idea and then modify it. When appropriate, the line feed operation uses<Esc>oIn this way, there will be a smaller granularity for revocation, which is conducive to encoding operations

6. In normal mode, pressdb, Reverse deletes the content from the starting position of the cursor to the beginning of the word, but the last character remains unchanged.

7. In normal mode, pressbWill move the cursor to the beginning of the word

8. In normal mode, pressdawTo delete a word.

9. In normal mode<C-a>And<C-x>Perform the add and subtract operations on numbers separately. When the number is not included, they are added or subtracted one by one. However, if the number prefix is included, you can use them to add or subtract any integer, for example, move the cursor to number 5 and execute10<C-a>It is changed to 15. If the cursor is not on the number<C-a>And<C-x>The system looks for a number in the forward direction of the current row. If it finds a number, it jumps directly to it.

10. In normal mode, pressyypThe current row is copied and pasted to the next row.

11. Adding the number of times in normal mode indicates repetition, for example2dwOrd2wBoth indicate to delete two words,2uIt indicates two steps to be rolled back, and so on, but it is best to use it only when necessary.

12. In normal mode, pressdlDelete words under the current cursor, but do not enter insert mode. PressdapDelete the entire paragraph

13. In vim, operator + action command = operation. When an operator is called twice consecutively, it acts on the current row. For example:ddDelete the current row,>>Indent the current row,gUThe command is a special case, you can usegUgU, You can also use the simplified versiongUUTo make it act on the current line. The common operator commands are as follows:

c: Modify
d: Delete
y: Copy to register
g~: Reverse case
gu: Convert to lowercase
gU: Convert to uppercase
>: Increase indentation
<: Reduce indentation
=: Auto indent
!: Use an external program to filter the rows that {motion} Spans


Vim common skills summary 2

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.