On śro lis 22 2006, Vim List wrote:
> In vim docs, there is example like this:
> g/pat/s/pat.*/to/
> As far as I know, it is also possible to do it without g:
> %s/pat.*/to/
> Is there a difference, a reason to prefer the
> first form, the longer for with 'g' ?
It is useful when you want to change some pattern but only in lines
where is other pattern. Example::
g/^#IDO/s/\\/\//g
It will change \ in / but only in lines beginning with '#IDO'.
Combining of g// and s/// with similar {from} string may be faster to
execute (not type ;) when s/// is very complex regexp. You prefilter
file to catch only lines where possibility of substitution is high and
later you only test this subset of lines. But it pays off only on big
files and complicated regexps.
m.