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
Said
Remove Delete
r
Said
replacing replace
c
Said
Modify Change
y
Said
Copy Yank
v
Said
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:
Prepositions
Prepositions define the range or position of the text to be edited. For example:
i
Said
"In ... Within "inside
a
Said
"Surround ..." around
t
Said
"To ... Position front "to
f
Said
"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:
动词 介词 名词
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.
# 删除一个段落: delete inside paragraph
dip
# 选取一个句子: visual select inside sentence
vis
# 修改一个单词: change inside word
ciw
# 修改一个单词: change around word
caw
# 删除文本直到字符“x”(不包括字符“x”): delete to x
dtx
# 删除文本直到字符“x”(包括字符“x”): delete forward x
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:
动词 介词/数词 名词
Here are a few examples:
# 修改三个单词:change three words
c3w
# 删除两个单词:delete two words
d2w
In addition, the numeral can also modify the verb, indicating that the operation is performed n times. So, we have the following syntax:
数词 动词 名词
Take a look at the example:
# 两次删除单词(等价于删除两个单词): twice delete word
2dw
# 三次删除字符(等价于删除三个字符):three times delete character
3x
What, isn't it easy to understand?
Together, the Vim language