18, vim into the editing mode, Vim command mode, VIM practice

Source: Internet
Author: User

18, vim into the editing mode, Vim command mode, VIM practice

First, vim into the editing mode

edit Mode : You cannot modify a character in general mode, and you can only enter edit mode if you want to modify the character. From general mode to edit mode, simply press I, I, A, A, O, O, R, and R for a key. When you enter edit mode, an INSERT or replace Word appears at the end of the screen (if your CentOS supports Chinese, "insert" is displayed). From edit mode back to normal mode, press ESC.

I: Insert in the current word match either.

I: Inserted at the beginning of the line where the cursor is located.

A: Insert in the current word specifier.

A: Inserted at the end of the line where the cursor is located.

O: Inserts a new row on the next line of the current row.

O: Inserts a new row on the previous line in the current row.

Second, vim command mode

Command mode : Enter: or/To enter command mode. In this mode, you can search for characters or strings, and you can save, replace, exit, display line numbers, and so on.

/word: Look for a string after the cursor word, press N to continue searching, shift+n search up.

Word: Look for a string before the cursor word, press N to continue searching backwards.

The searched string will be highlighted, if you want not to highlight, enter: Nohl.

: N1,n2 s /word1/word2/g: Find word1 between N1 and N2 rows and Replace for Word2, No G replaces only the first one in each row word1. (The starting point is then separated by commas, and then the end point S means replace/replace/replace the/g to indicate all.) $ represents to the end)

: 1, $s/word1/word2/g: replaces all word1 in the document with Word2, and no G replaces only the first word1 of each row.

Special Cases :: 1, $s//etc/hosts/aminglinux.com/g; replace/etc/hosts with aminglinux.com, because there are multiple slashes, so it is not recognized, so to push, the system will/etc/ The hosts ' slashes are treated as ordinary characters,

: 1, $s/ \ / etc \ /hosts/aminglinux.com/g, add two right slash.

You can also change the original slash to # or @,:1, $s #/etc/hosts#aminglinux.com#g, so that the character is composed of # or @ as its syntax.

Other Features:

: W saves the text.

: Q quit Vim.

: w! Force save, under root user, even if the text is read-only can be saved.

: q! Force exit, all changes will not take effect.

: Wq save exit.

: X is similar to Wq, after changing the file, Wq and X are the same, and if the file is not changed, the mtime of the file will change, and X will not.

: Set NU Displays line numbers.

: Set Nonu does not display line numbers.

Third, Vim practice

If you do not/etc/dnsmasq.conf this file, you need to install the package yum install Dnsmasq-y

Restart DNSMASQ Services: # service DNSMASQ start


Special usage of VIM


Vim Common shortcut key summary


Vim quickly deletes a segment of characters


Vim garbled


Keypad issues


VIM encryption


18, vim into the editing mode, Vim command mode, VIM 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.