Vim uses advanced

Source: Internet
Author: User

1) command-line mode: The typed content is interpreted as a command.

2) Insert mode: The type of content is inserted into the file.

3) Visual mode: Select, cut, and copy text from the keyboard.

4) Ex mode: Use more commands (for example: storing files, replacing text, etc.).

When the blogger first touches vim, it also tries to use it like any other editor, that is, to go into the insert mode and do the clumsy work. In fact, the true power and speed of vim lies in its command-line mode. After a true mastery of vim, it is found that the use of insertion mode is less time and more prone to use convenient command-line mode.

First, about turn off and mode switch

You can start vim with the following command:

$ vim Test.txt

The document is then opened, but cannot be edited, and Vim is in command-line mode. You can use the keyboard to perform VIM commands in this mode.

To insert text, position the cursor to the insertion position (the following sections describe the efficient cursor positioning method), and then press I to enter insert mode.

Press ESC to return to the command-line mode.

After editing, enter: Wq and return can save exit, or: q! can not save exit.

In the command-line mode, there are some notable areas:

1): E <path/to/file>→ Open a file

2): w→ disk

3): SaveAs <path/to/file>→ Save As <path/to/file>

4): X, ZZ or: wq→ Save and exit (: X means save only when needed, ZZ does not need to enter a colon and return)

5): q! → Exit does not save: qa! Forcibly exits all files being edited, even if other files have changed.

6): bn and: bp→ When you open many files at the same time, you can toggle the next or previous file with these two commands.

Vim uses advanced

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.