Basic commands commonly used by vim

Source: Internet
Author: User

Basic commands commonly used by vim
1. w [filename] is equivalent to save as
2. R [File name] Add the contents of [filename] after the cursor line
3. N1,n2 W[filename] Save the contents of N1 to N2 as [filename]
4.50DD Delete 50 lines 5x Delete 5 characters
5.20 Downward move 20 rows
6.50G Move to line 50th
7.20 Move right 20 bit
8./word Find Word string

9.  text substitution
:50,100s/man/man/g      replace the man between rows 50 through 100 with man
:s/str1/str2             Replace the current line the first str1 is str2       --  s represents the current line
:s/str1/str2/g          replaces all str1 in the current row as str2& nbsp;     --  s represents the current row     G means that all global[g in the row can be appended with a C, indicating that each substitution is confirmed under]
: m,ns/ str1/str2         replaces the first str1 of each row in the beginning of the nth row to the last row is str2
: m,ns/str1/str2/g        Replace the nth line start to the last row with all str1 as STR2
:%s/str1/str2/g          Replace all str1 in the text as str2

Copy Delete block action
V Character selection
V-Line Selection
Ctrl + V block selection
Y copy p paste d Delete

Word movement
W W move to the beginning of the next word
E e moves to the end of the next word
b b backwards to the beginning of the previous word
It is important to note that E ignores punctuation, such as: I ' m,e will be two words, E won't
Similarly, precede the command with a number that represents the number of executions, such as: 2w, to move 2 words down
I may say a few more times at the beginning, because this technique is important.

The entire row moves,
0 move to the beginning of the line
$ move to end of line
+ Move to the beginning of the next line
-Move to the beginning of the previous line

Roll screen
Ctrl+f Scroll forward a full screen
Ctrl+b Scroll back a full screen
Ctrl+d rolling forward half screen
Ctrl+u rolling back half screen


Show all lines where a word is located [+ SHIFT + I

Basic commands commonly used by vim

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.