[英]VIM language syntax
I am interested in understanding this from the point of view of the VIM grammar: 我有兴趣从VIM语法的角度理解这一点:
The general syntax for the operations is (as per vimtutor): 操作的一般语法是(根据vimtutor):
operator [number] motion
However, for some operators like f
, the syntax is: 但是,对于某些运算符,如
f
,语法为:
[number] f motion
I find this confusing and mess it up almost every time. 我觉得这很混乱,几乎每次都会搞砸。 Could someone please point out the logic (from the VIM Language perspective)?
有人可以指出逻辑(从VIM语言的角度来看)吗?
Thanks. 谢谢。
In my eyes f
is not an operator but a motion : fx
moves the cursor to the next appearance of x
. 在我看来,
f
不是运算符,而是动作 : fx
将光标移动到x
的下一个外观。
See this example for clarification: 请参见以下示例以进行澄清:
dfx
"delete find x" deletes everything up to (including) the next x dfx
“删除查找x”删除直到(包括)下一个x的所有内容 d5fx
deletes to 5th x (including) d5fx
删除到第5 x(包括) Both examples follow the grammar operator [number] motion
: 这两个示例都遵循语法
operator [number] motion
:
d
operator d
运算符 5
number 5
号 fx
motion fx
运动 Looking at the f
-command this way may clear up your confusion. 以这种方式查看
f
命令可能会消除您的困惑。
Motions are generally used to move the cursor around. 通常使用运动来移动光标。 They can be prepended by an operator (another example:
j
moves to line below, dj
applies delete-operator to line below, 5dj
does it 5 times). 它们可以由运算符添加(另一个示例:
j
移至下面的行, dj
将delete-operator应用于下面的行, 5dj
5次)。
f
is not an operator so there's no reason to assume it should work like an operator. f
不是运算符,因此没有理由假设它应该像运算符一样工作。
f
is a motion… and it pretty much works like a motion, as expected. f
是一个运动……而且,正如预期的那样,它几乎像一个运动一样工作。
See :help operator
for the complete list of available operators and take a look at the section to which :help f
belongs. 有关可用运算符的完整列表,请参见
:help operator
符,并查看:help f
所属的部分。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.