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:

    • D for deletion (delete)
    • R = Replacement (replace)
    • C indicates modification (change)
    • Y means copy (yank)
    • V indicates selection (visual Select)
Noun

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

    • W represents a word (word)
    • s represents a sentence (sentence)
    • P represents a paragraph (paragraph)
    • T denotes 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:

    • I mean "in ... Within "(inside)
    • A means "wrapping ..." (around)
    • T means "to ... Position front "(to)
    • F means "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:

Verb prepositions nouns

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.

# Remove a paragraph: Delete inside paragraphdip# Select a sentence: Visual Select inside sentencevis# Modify a word: Change inside wordciw# Modify one word: Cha Nge around wordcaw# Delete text until character "X" (not including character "X"): Delete to xdtx# remove text until character "X" (including character "X"): Delete forward xdfx
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:

Verb prepositions/numeral nouns

Here are a few examples:

# Modify three words: Change three wordsc3w# delete two words: Delete two wordsd2w

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

numeral verb noun

Take a look at the example:

# two Delete words (equivalent to delete two words): twice delete word2dw# three delete characters (equivalent to delete three characters): three times Delete character3x

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.