Vim frequently used tips Summary 2

Source: Internet
Author: User

1. Find the character in the line where the cursor is. Use the f{char} command in normal mode, and the cursor will move to the position where the character is located. Find it down repeatedly in normal mode;

2. Find and replace in the line where the cursor is located in normal mode: s/target/replacement, where target and replacement are replaced by the replaced character or string and the replaced character or string, respectively, and repeatedly used in normal mode. command. Rollback in normal mode u

Manually control each replacement in normal mode with :%s/target/replacement/gc , in which case Vim will ask for replacement whenever there is a replacement, with the following options:
y: replace here to match
n: ignore the match here
a: "all" - replace all matches here and after
l: "last" - replace here to match and exit
q: Exit the replacement process
<C-e>: Scroll up the screen
<C-y>: Scroll down the screen

3. Find the word under the current cursor in normal mode. *

4, one-click move, there is a one-click change - . Paradigm

5, when writing code thinking pause, please return to the normal mode, cut the thinking unit into blocks, so that it is convenient to make mistakes. In the normal mode, press u to retreat the operation and then change the previous ideas. When appropriate, the newline operation uses <Esc>o, which will result in a smaller granularity when undoing, which is good for encoding operations.

6. Press db in normal mode to delete the content from the cursor start position to the beginning of the word in reverse, but leave the last character intact.

7. Press b in normal mode to move the cursor to the beginning of the word

8. Press daw in normal mode, which is "delete a word". Delete a word

9. In normal mode, <C-a> and <C-x> respectively add and subtract operations to the numbers. When running without a number of times, they are added and subtracted one by one. But assume a prefix with a number. Then you can use them to add and subtract random integers, such as we move the cursor to the number 5. Running 10<C-a> will turn it into 15. If the cursor is not on the number, then <C-a> and <C-x> will look up a number in the forward direction of the current line, assuming it is found. It just jumped there

10. Pressing yyp in normal mode will copy the current line and paste it to the next line.

11, in the normal mode plus the number of repeated, such as 2dw or d2w means to delete two words, 2u means two steps back, etc., but it is best to use only when necessary

12. Press dl in normal mode to delete the word under the current cursor, but not enter the insert mode. Press dap to delete the entire paragraph

13. In Vim, the operator + action command = action, when an operator is called twice in succession. It will act on the current line, such as: dd delete the current line. >> Indent the current line. However, the gU command is a special case that can be used with gUgU or gUU with a simplified version number to make it work on the current line. The frequently used operator commands are as follows:

c: change
d: delete
y: copy to register
g~: reverse uppercase and lowercase
Gu: convert to lowercase
gU: convert to uppercase
>: Add indentation
<: reduce indentation
=: Self-indentation
!: Use an external program to filter the lines spanned by {motion}

Vim often uses tips 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: 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.