vimで大文字と小文字を区別して使いたいのですが、うまくいき:substitute(...)
ません。
操作したい変数は次のとおりです。
let s:Var = 'foo BAR baz'
もちろん、次の行(s:Var の) が置換されないように明示的に設定することもできます。noic
BAR
set noic
let s:S1 = substitute(s:Var, 'bar', '___', '')
" print foo BAR baz
echo s:S1
逆に、ic
が設定されている場合はBAR
、もちろん置換されます。
set ic
let s:S2 = substitute(s:Var, 'bar', '___', '')
" print foo ___ baz
echo s:S2
I
さて、大文字と小文字を区別するためにフラグを使用できると思い:substitute
ましたが、そうではないようです:
let s:S3 = substitute(s:Var, 'bar', '___', 'I')
" print foo ___ baz
" instead of the expected foo BAR baz
echo s:S3
I
フラグのヘルプは次のとおりです。
[I] Don't ignore case for the pattern. The 'ignorecase' and 'smartcase'
options are not used.
{not in Vi}
これらの行についての私の理解では、そのフラグでは BAR を代用すべきではありません。