The help message about [I]
you quoted is not for substitute()
function. it is for :s
command.
The flag of substitute()
function could have either "g"
or ""
. if you want to do case sensitive match with this function, add \C
in your pattern, like:
substitute(s:Var, '\Cbar', '___', '')
check this help text:
The result is a String, which is a copy of {expr}, in which
the first match of {pat} is replaced with {sub}.
When {flags} is "g", all matches of {pat} in {expr} are
replaced. Otherwise {flags} should be "".
This works like the ":substitute" command (without any flags).
But the matching with {pat} is always done like the 'magic'
option is set and 'cpoptions' is empty (to make scripts
portable). 'ignorecase' is still relevant, use |/\c| or |/\C|
if you want to ignore or match case and ignore 'ignorecase'.
'smartcase' is not used. See |string-match| for how {pat} is
used.