引用:h operator
中提到的运算符列表:
The motion commands can be used after an operator command, to have the command
operate on the text that was moved over. That is the text between the cursor
position before and after the motion. Operators are generally used to delete
or change text. The following operators are available:
|c| c change
|d| d delete
|y| y yank into register (does not change the text)
|~| ~ swap case (only if 'tildeop' is set)
|g~| g~ swap case
|gu| gu make lowercase
|gU| gU make uppercase
|!| ! filter through an external program
|=| = filter through 'equalprg' or C-indenting if empty
|gq| gq text formatting
|g?| g? ROT13 encoding
|>| > shift right
|<| < shift left
|zf| zf define a fold
|g@| g@ call function set with the 'operatorfunc' option
从
:h operator
引用可视模式如何与运算符一起使用:Instead of first giving the operator and then a motion you can use Visual
mode: mark the start of the text with "v", move the cursor to the end of the
text that is to be affected and then hit the operator. The text between the
start and the cursor position is highlighted, so you can see what text will
be operated upon. This allows much more freedom, but requires more key
strokes and has limited redo functionality.
因此,我了解到,如果我在可视模式下选择了几个单词并按d,则所选单词将被删除,因为
d
运算符可以通过运动键或在可视模式下选择文本来指定其操作数。但是我看到,如果我在可视模式下选择了几个单词并按x,那么所选单词也会被删除。但是
x
不是运算符。在可以正常工作的同时,我无法从Vim的帮助中了解。您能否帮助我了解哪些命令适用于在可视模式下选择的文本,哪些命令无效,以及如何从Vim的帮助中了解这一点?
最佳答案
首先,d
和:d[elete]
不删除,它们被剪切。对于d
使用删除一词是一个严重的错误,在Vim的文档中以及在几乎在线的所有地方都屡屡出现。使d
和 friend 实际删除某些东西的唯一方法是使用“黑洞”寄存器:help "_
。
其次,通过从引用的:help
向下滚动几下,您可以找到问题的答案:
Additionally the following commands can be used:
: start Ex command for highlighted lines (1) |v_:|
r change (4) |v_r|
s change |v_s|
C change (2)(4) |v_C|
S change (2) |v_S|
R change (2) |v_R|
x delete |v_x|
[…]
并通过阅读
:h x
并再次向下滚动一点,或更简单地说,跟随该行末尾的v_x
标签。您的问题写得很好,而且布局合理,但是您应该更加明智地花费时间和精力。例如,阅读超过第一个屏幕。