Search and Replace in Vim

I hadn’t used this is a while and needed to change the IP address in a named.conf file.  This is not a full tutorial, it’s just a quick and simple howto for search and replace in Vi(m)

Here is the format :%s/search/replace/gc

For example I want to change aaa.bbb.ccc.ddd to


The g means global,  ie do it for multiple occurrences on a single line.
The c means give a confirmation prompt ( you can leave this off if you are confident or crazy)

Be the first to comment

Leave a Reply

Your email address will not be published.


This site uses Akismet to reduce spam. Learn how your comment data is processed.