Vim 中替代和更改之间的区别

Gre*_*hon 2 vi vim

s在 Vim 中,和 之间有什么区别c?如果我替换n个字母或单词,改变它们有什么区别吗?替代和改变是否有不同的情况?

jer*_*ile 5

如有疑问,请检查:help

:help s

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

Run Code Online (Sandbox Code Playgroud)

: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.
Run Code Online (Sandbox Code Playgroud)

TL;DR: c采取正常的动作(例如cw更改您所在的单词)来确定在输入插入之前要删除多少文本。s使用一个数字(例如10s)来确定在输入插入之前要删除多少文本。话虽这么说,您可以通过使用 , <num>s(帮助中提到,事实上,这是 的同义词)。cc<num>lscl