即使不是操作员,Vim中的x命令如何处理在视觉模式下选择的文本?

即使不是操作员,Vim中的x命令如何处理在视觉模式下选择的文本?,vim,Vim,引用: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 t

引用
: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
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的帮助中了解这一点吗?

您是对的,操作员命令通常对视觉模式进行运动更改,而您不指定运动,而是让命令对所选文本进行操作。但这只是在视觉模式下工作的一组命令

另一组包含在当前/
[count]
字符或行上工作(无运动)的正常模式命令,如
x
r
J
。在视觉模式下,这些选项也适用于选定的文本


这会在视觉模式中产生一些重叠,例如,
d
x
都做相同的操作,而在正常模式下,
d5l
5x
会有所不同。

首先,
d
:d[elete]
不删除,而是删除。用delete这个词来表示
d
是一个严重的错误,Vim的所有文档都重复了这个错误,因此几乎所有的在线文档都重复了这个错误。要让
d
和朋友真正删除某些内容,唯一的方法是使用“黑洞”寄存器,
:help“\u

其次,您可以从您引用的
: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|
    […]
通过阅读
:hx
,再次向下滚动一点,或者更简单地说,跟随行末尾的
vux
标记


您的问题写得很好,布局也很好,但您应该更明智地使用您的时间和精力。例如,阅读第一个屏幕。

您能告诉我如何理解哪些其他命令(操作员除外)在视觉模式下选择文本后可以使用吗?我正在尝试学习如何自己从
:help
中计算这些信息,如果我将来忘记它。所有视觉模式命令在帮助中都以
v_
为前缀。
:help v_
将列出它们。我是在尝试
:help v_
时得到这些信息的:
E419:对不起,没有与Vim的帮助中一样,v_uu的帮助意味着按下Ctrl+D。我知道
D
会(默认情况下)剪切到寄存器x。我只选择使用文档中使用的语言。感谢您对我的问题的反馈以及阅读更多文档的建议。谢谢!