r
在此vim搜索和替换命令结束时执行了什么操作::%s/foo/bar/r
?
答案 0 :(得分:2)
要在最后找出 r 的含义,只需在:help :substitute
中输入vim
:
[r] Only useful in combination with `:&` or `:s` without arguments. `:&r`
works the same way as `:~`: When the search pattern is empty, use the
previously used search pattern instead of the search pattern from the
last substitute or `:global`. If the last command that did a search
was a substitute or `:global`, there is no effect. If the last
command was a search command such as "/", use the pattern from that
command.
For `:s` with an argument this already happens: >
:s/blue/red/
/green
:s//red/ or :~ or :&r
因此,在您的情况下,命令:%s/foo/bar/r
与:%s/foo/bar/
具有完全相同的效果,这会将仅foo
的第一次更改为bar
}在包含搜索模式的每一行(这里都是foo
)