Together, the Vim language

Source: Internet
Author: User

As an old and enduring editor, Vim has its own strengths. Many people think that Vim's learning curve is too steep, in order to be able to use VIM, have to memorize a large number of commands. If you are new to Vim, just start to face a vast amount of command-by-article learning, I believe you will gradually lose interest in it. In fact, Vim helps you with text editing in a nearly natural language way. Just be familiar with a few simple grammars, and you'll sit back and forth in the revolving seat, feeling the beauty of life coming again.

Let's say you already know some of the most common working modes of Vim (normal mode, insert mode, command mode, etc.), and if you don't know it, read it first. Now let's learn the Vim language together.

Verb

The verb represents what we intend to do with the text. For example:

    • dSaid

      Remove Delete
    • rSaid

      replacing replace
    • cSaid

      Modify Change
    • ySaid

      Copy Yank
    • vSaid

      Select Visual Select

Noun

Nouns represent the text we are about to process. There is a special term in Vim called the text object, which is an example of some text objects:

    • wRepresents a

      Word Word
    • sRepresents a

      Sentence sentence
    • pRepresents a

      Paragraph paragraph
    • tRepresents an HTML

      Tag tag
    • The quotation marks or the text contained in the various parentheses are called a block of text.

Prepositions

Prepositions define the range or position of the text to be edited. For example:

    • iSaid

      "In ... Within "inside
    • aSaid

      "Surround ..." around
    • tSaid

      "To ... Position front "to
    • fSaid

      "To ... Location "forward

Here are a few of the areas that you should feel:


Prepositions

Group words as Sentences

With these basic language elements, we can begin to construct some simple commands. The basic syntax for text editing commands is as follows:

    1. 动词 介词 名词

Here are some examples (if you are familiar with the above concepts and you will see these examples are very easy to understand), please try it yourself in Vim.

  1. # 删除一个段落: delete inside paragraph

  2. dip

  3. # 选取一个句子: visual select inside sentence

  4. vis

  5. # 修改一个单词: change inside word

  6. ciw

  7. # 修改一个单词: change around word

  8. caw

  9. # 删除文本直到字符“x”(不包括字符“x”): delete to x

  10. dtx

  11. # 删除文本直到字符“x”(包括字符“x”): delete forward x

  12. dfx

Numerals

Numerals specify the number of text objects to be edited, and from this point of view, numerals can also be regarded as a preposition. After the introduction of the numeral, the syntax of the text Editing command is escalated to the following:

    1. 动词 介词/数词 名词

Here are a few examples:

    1. # 修改三个单词:change three words

    2. c3w

    3. # 删除两个单词:delete two words

    4. d2w

In addition, the numeral can also modify the verb, indicating that the operation is performed n times. So, we have the following syntax:

    1. 数词 动词 名词

Take a look at the example:

    1. # 两次删除单词(等价于删除两个单词): twice delete word

    2. 2dw

    3. # 三次删除字符(等价于删除三个字符):three times delete character

    4. 3x

What, isn't it easy to understand?

Together, the Vim language

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.