[plug] re: replacing text in search
Bernd Felsche
bernie at innovative.iinet.net.au
Sat Aug 2 22:17:49 WST 2003
On Sat, Aug 02, 2003 at 02:41:46PM +0800, Craig Ringer wrote:
> >In vim how do I do a search and replace for the following
> >/sbin/iptables? I've tried %s//sbin/iptables/g but this does not work.
> >I'm need to include the / character in the search.
>
> :1,$s/\/sbin\/iptables/REPLACEMENTTEXT/g
>
> At least, if you want to do an automatic find-and replace across the
> entire document, replacing all instances not just the first one on a
> line, this is what you'll want. Note the use of escapes on the slashes,
> and the trailing /g to ensure it replaces every instance.
>
> I'm not sure if there's a way to avoid having to use the :1,$ notation
% is equivalent to all lines.
How's that for a 66.67% reduction in your workload? :-)
> to say 'all of file' but when I've tried to use s regex without this, ie
> :s/blah/bloh/g
> it fails.
--
/"\ Bernd Felsche - Innovative Reckoning, Perth, Western Australia
\ / ASCII ribbon campaign | I'm a .signature virus!
X against HTML mail | Copy me into your ~/.signature
/ \ and postings | to help me spread!
More information about the plug
mailing list