Darren Beale Web developer & early adopter

Global search and replace using Vi


to replace all instances of – say – with in a file then using vi you can do:


if you mess it up then press u for undo. Of course if it's an important file then back it up first.

<span class="dsq-postid" data-dsqidentifier="265 http://bealers.com/2006/04/28/global-search-and-replace-using-vi/">3 comments</span>

  • Do you think maybe you could have used a simpler example without all of the escapes for the .’s ? how about this? Replace all instances of overcomplicated in a file:


  • Your example is actually a good one. The fact is that a very common use for global search/replace in vii is to replace ip addresses in .conf files. This example perfectly illustrates doing just that, and is unlikely to confuse anyone with even some experience with posix type os.

By bealers
Darren Beale Web developer & early adopter