First of all, open :h :s
to see the section "4.2 Substitute" of documentation on "Change". Here's what the command accepts:
:[range]s[ubstitute]/{pattern}/{string}/[flags] [count]
Notice the description about pattern
and string
For the {pattern}
see |pattern|
.
{string}
can be a literal string, or something
special; see |sub-replace-special|
.
So now you know that the search pattern and replacement patterns follow different rules.
If you follow the link to |pattern|
, it takes you to the section that explains the whole regexp patterns used in Vim.
Meanwhile, |sub-replace-special|
takes you to the subsection of "4.2 Substitute", which contains the patterns for substitution, among which is \r
for line break/split.
(The shortcut to this part of manual is :h :s%
)
%
for when searching and replacing? – qed:s
will only apply the substitution to the current line.:%s
makes it address the whole file. More. – c24w