In Vim, what is the difference between s
and c
? If I substitute n letters or words, is there any difference to changing them? And are there any instances where substituting and changing are different?
When in doubt, check the :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
takes normal movements (like cw
to change the word you're on) to determine how much text to delete before entering insert. s
takes a number (like 10s
) to determine how much text to delete before entering insert. That being said, you could do <num>s
with c
, by using c<num>l
(and the help mentions that s
is, in fact, a synonym for cl
).