Vim's simple operation

Source: Internet
Author: User

Press ESC to enter command mode

1. Replace

:%s/str1/str2/g replaces all str1 in each row as str2

: S/str1/str2/g replaces all str1 in the current line as str2

: N1,n2s/str1/str2/g replaces N1 line to N2 row in all str1 to STR2

Note: Removing/g means replacing only the first str1 that match to STR2

2. Case conversion

:%s/[a-z]/\u&/g U converted to uppercase

:%s/[a-z]/\l&/g L Convert to lowercase

:%s/\w*/\u&/g The first letter of each word into uppercase

:%s/\w*/\u&/g all words into uppercase

GGGUG Full Capitalization

Note: L (lowercase L): The first letter of the word is converted to lowercase, L: All words are converted to uppercase, \w: Match words

3. Add

:%s/^/str add str content at the beginning of each line

:%s/$/str add str content at the end of each line

: N1,n2s/^/str add Strneir to the beginning of line N1 N2

Note: ^ Indicates the beginning of a line, and $ indicates the end

4. VI Common CommandsH,j,k,l: Move left, bottom, top, and right (single character move)? Ctrl-b,ctrl-f: Up and down? W,b,e,ge: The next word, the first word, the next word ending, the last word ending? W,b,e,ge: Similar to the above function, but not with the word as the demarcation, but with the blank as the demarcation? H,m,l: The top, middle, and tail of the current window? ZT,ZZ,ZB: Scroll at the cursor position, top, middle, tail? f/f,t/t: f/f-character, move to the specified character (f is reversed), t/t-character, move to the specified word match either (T is reverse)?; , . : Repeat the last f/f,t/t command, while the opposing counter repeats the f/f,t/t command,. command, repeat last modified action? : Enter/In normal mode, then enter find content, can implement find, press n/n, hit on/off? *: Find all the words in the cursor? r,r,~: Single-character replace, continuous replace, change case? CW,CB: Modify from the cursor to the end of the word, from the cursor to the beginning of the word? C $ /C,C0,CC: From the cursor to the end of the line, from the cursor changes to the beginning of the bank, delete the entire row from the beginning to modify? S,s: Delete the entire line, modify it from scratch, remove the character from the cursor, and insert? YY,Y^,Y$,YW, YG: Copy the current line, the cursor to the wardrobe, the cursor to the end of the line, the cursor to the ending of the word, the cursor to the tail? DD,D^,D$,DW,DG: Cut command, similar to the upper y behavior? p/p : After pasting the cursor, before? $: Move to the end of the line where the cursor is located? ^: moves to the beginning of the line where the cursor is located

Vim's simple operation

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.