Vim 中替代和变化的区别

Difference Between Substitute and Change in Vim

在Vim中,sc有什么区别?如果我替换 n 个字母或单词,改变它们有什么不同吗?有没有替换和改变不同的情况?

如有疑问,请检查 :help:

:help s

                            *s*
["x]s           Delete [count] characters [into register x] and start
            insert (s stands for Substitute).  Synonym for "cl"
            (not |linewise|).

:help c

                            *c*
["x]c{motion}       Delete {motion} text [into register x] and start
            insert.  When  'cpoptions' includes the 'E' flag and
            there is no text to delete (e.g., with "cTx" when the
            cursor is just after an 'x'), an error occurs and
            insert mode does not start (this is Vi compatible).
            When  'cpoptions' does not include the 'E' flag, the
            "c" command always starts insert mode, even if there
            is no text to delete.

TL;DR: c 进行正常移动(如 cw 更改您所在的单词)来确定要删除多少文本在进入插入之前。 s 使用一个数字(如 10s)来确定在输入插入之前要删除多少文本。话虽如此,您可以通过使用 c<num>lc 执行 <num>s(并且帮助中提到 s 实际上是 cl 的同义词).