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:

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 that represents a sentence (sentence) p indicates that a paragraph (paragraph) t represents an HTML tag (tag) quotation mark or the text contained in various parentheses is 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 before "(to) F" means "to ... Location "(forward)

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

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.

Select inside sentencevis# Modify a word: Change inside wordciw# Modify a word: Changes around wordcaw# delete text until the character "X" (excluding the character "X"): Delete to XD tx# Delete text until the character "X" (including the 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?

In this article, the Vim language

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.