Vim Recipes translation-Choosing The Right Mode

Source: Internet
Author: User
Document directory
  • Select The Right Mode)

You can download the original Vim Recipes text from runpaint.

Select The Right Mode)

 

Problem

Although you know that Vim has multiple operation modes, you are not sure when to use them.

 

Solution

There are four common modes:

Insert mode)

It is only used for input, not in this mode. Minimize the time required to use this mode.

Normal mode)

Edit in this mode: Move in the file, change the text content, and rearrange the text structure. In this mode, you usually need to enter and exit the insert mode in due time.

Visual mode)

Select text in this mode to cut, copy, or format the selected text.

Command-Line mode)

In this mode, enter the command line, for example, set number.

 

Discussion

The Vim mode seems confusing, but it is the key to understanding Vim.

We are often tempted by the Insert mode. We spend a lot of time in the Insert mode and use the arrow keys (arrow keys) to browse the text. However, this method is slow and requires more buttons.

Normal mode is the default mode of vim, because in Normal mode, it is easier to move in the file, and the location where you want to edit or prepare to insert text is faster.

In insert mode, you can use <ctrl> + o to temporarily enter normal mode (the command is automatically returned to insert mode after one edit ). For example, in Insert mode, use <ctrl> + o gqas to enter Normal mode, format the current section, and return to Insert mode.

For example, if you want to find and override a paragraph, you can search for this paragraph in Normal mode (e.g. /Hobson argued), or to the paragraph (e.g. use <ctrl> + F to scroll down ). After finding it, you can use basic mobile commands or text objects to move the part you are interested in. Then, you can use the text object to select some text for modification. For example, use caw to delete the current word and enter the insert mode. After the task is completed, press <Esc> to return to Normal mode again.

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.