Vim edit mode, command mode, and practice

Source: Internet
Author: User
Tags save file

Press I to enter edit mode
Press I (I in uppercase) to enter edit mode and the cursor jumps to the beginning of the cursor position
Press O to start editing from the next line of the cursor
Press O (capital O) to start editing from the previous line on the row where the cursor is located
Press A to start editing from the back of the cursor position
Press A (capital a) to start editing from the end of the line where the cursor is located

Second, the command mode

In command mode, enter the content that/+ needs to search, such as/DNSMASQ, to find DNSMASQ
Command mode input? + What you need to search for, look up
Input format in command mode: The number of start lines to replace, the number of end lines to replace/content to replace/target content to replace/g (s = start substitution; g = global substitution, replace all; no g means replace only the first character content)
Cases:
: 1,100s/dnsmasq/qwerty/g//Replace all DNSMASQ in line 1th-row 100 with QWERTY
: 1, $s/dnsmasq/qwerty/g//Replace all DNSMASQ in the file with a QWERTY ($ means all in the file)
: 1, $s/\/etc/\/hosts/qwerty/g//Replace all/etc/hosts in the file with a QWERTY
: 1, $s #/etc/hosts#qwerty#g//Use the # symbol to separate the/etc/hosts
: 1,[email protected]/etc/[email protected]@g//Use the @ symbol to separate the/etc/hosts
(Tip: Press the colon + UP ARROW key to find the last command you used)
: Wq Save Exit
: wq! Force Save exit
: W Save File
: w! Force save File
: Q exit
: q! Force exit
: Set NU Displays line number
Set Nonu does not display line numbers
: Nohl does not display highlighting
: x After changing files: X and: Wq effect

Third, Vim practice


Vim edit mode, command mode, and practice

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.