I am wondering how to use regular expression to specify directories to be found and replaced inside vim.
For example: Changing the default DocumentRoot and Directory in httpd.conf.
Normally I use the following command to find and replace individual strings in vim, but this does not work for directories
:%s/tobefound/tobereplaced/g
ACCEPTED]
Suppose that you had:
DocumentRoot /var/www/html
And you wanted to change /var/www/html to /home/web, you could do:
:%s,/var/www/html,/home/web,g
There's nothing "special" about /, it's just a common field delimiter. You can use other characters; in my example I used ,
Any / characters in both tobefound and tobereplaced will need to be escaped to \/, otherwise it will be interpreted as part of the syntax of the find and replace command.
E.g. replacing /tmp/abc/ with /srv/def/ would require %s/\/tmp\/abc\//\/srv\/def\//g