Vim视觉选择和正则表达式

Gre*_*lds 6 vim

我遇到了视觉选择问题并运行正则表达式替换.当我选择一些不包含整行的文本时,点击:将命令行引出,并执行类似的操作

:s/T/t/
Run Code Online (Sandbox Code Playgroud)

然后改变该线上的第一场比赛(无论是否被选中).所以,例如,我有文字

Test Text here
Run Code Online (Sandbox Code Playgroud)

我在视觉上选择了单词Text,然后运行上面的替换,我最终得到了

test Text here
Run Code Online (Sandbox Code Playgroud)

这不是我想要的.

任何想法如何实现正确的结果?

编辑:实际的命令行是

'<,'>s/T/t/
Run Code Online (Sandbox Code Playgroud)

当你按下时,由Vim默认:通过视觉选择.

seh*_*ehe 10

您可以使用\%V(参见http://vimdoc.sourceforge.net/htmldoc/pattern.html#//%V)

\%V   Match inside the Visual area.  When Visual mode has already been
    stopped match in the area that |gv| would reselect.
    This is a |/zero-width| match.  To make sure the whole pattern is
    inside the Visual area put it at the start and end of the pattern,
    e.g.:
        /\%Vfoo.*bar\%V
    Only works for the current buffer.
Run Code Online (Sandbox Code Playgroud)

所以:

:s/\%VT/t/
Run Code Online (Sandbox Code Playgroud)

如果要替换多个匹配,请添加/ g

:s/\%VT/t/g
Run Code Online (Sandbox Code Playgroud)