The examples you are referring to are not examples of strings, but of patterns. A pattern may be delimited by any character (except alphanumeric characters), although the most usual one is /
. This does not seem to be very well documented, but I found it described under :h E146
, which reads as follows:
Instead of the '/' which surrounds the pattern and replacement string, you
can use any other single-byte character, but not an alphanumeric character,
'\', '"' or '|'. This is useful if you want to include a '/' in the search
pattern or replacement string. Example:
:s+/+//+
Strings, on the other hand, are either literal strings, e.g. 'this is a literal string'
, or "expression" strings, e.g. "this is an expression string"
. See :h expr-string
and :h literal-string
. The difference is that the expression string accepts special characters that are parsed, e.g. special keys such as "\<cr>"
, while literal strings are taken as is, except that double quotes are treated as a single quote.
:echo /foo/
it won't work. But in the substitutions commands for example you can use different characters (see my question here) if you scroll some more lines you'll see that the help also provides an example with+
as patterns delimiters.