为什么在单词内部更改案例时会改变行为?

Stu*_*ick 1 vim

我正在将一些单词改为大写,我点击viw~将单词的大小写从小写改为大写.我向前移动了一个单词并点击.以重复对下一个单词的操作,我注意到它影响了前面单词的一些字母的情况,而在其他时候它不会改变整个单词的大小写.

这是一个vim -u NONE带有单个句子的文件的例子

这是一个测试句

用我的光标在句子的开头,我viw~ 现在点击 我的句子:

这是一个示例测试句子

我向前移动1个单词w并点击.重复动作.我的句子现在是:

这是一个示例测试句子

w.

这是一个例子测试句子

w.

这是一个eXAMple测试句

w.

这是一个eXAMple TEST句子

当我将操作捕获为宏而不是使用时,会发生相同的行为 .

我怀疑vim只是改变了与第一个单词相同数量的字母的情况,但为什么呢?为什么viw不在宏中工作?

rom*_*inl 5

在与上一个命令覆盖的区域相当的区域上重复该操作.这与宏无关.

来自:help .:

Note that when repeating a command that used a Visual selection, the same SIZE
of area is used, see visual-repeat.
Run Code Online (Sandbox Code Playgroud)

来自:help visual-repeat:

When repeating a Visual mode operator, the operator will be applied to the
same amount of text as the last time:
- Linewise Visual mode: The same number of lines.
- Blockwise Visual mode: The same number of lines and columns.
- Normal Visual mode within one line: The same number of characters.
- Normal Visual mode with several lines: The same number of lines, in the
  last line the same number of characters as in the last line the last time.
The start of the text is the Cursor position.  If the "$" command was used as
one of the last commands to extend the highlighted text, the repeating will
be applied up to the rightmost column of the longest line.
Run Code Online (Sandbox Code Playgroud)

Vim的优势之一是您在执行许多操作之前无需选择文本.在这种情况下,您应该使用:help g~运算符,这将以.更直观的方式重复:

g~iw
Run Code Online (Sandbox Code Playgroud)

代替:

viw~
Run Code Online (Sandbox Code Playgroud)

演示