How I used vim to replace paths in an nginx config

Due to my tendency to drink from a firehose whenever I get into something new, when today I got up against the need to replace three paths in an nginx config, instead of manually entering insert mode, going to the lines, deleting the text, and writing in the new text, I decided to learn how to search and replace text that had slashes in them.

Now, for vim advice I of course go to Daniel Miessler’s Learn vim For the Last Time: A Tutorial and Primer, but in this case I found the following one-liner in Stack Overflow contributed by Sarah Vessels:

:%s/\/Users\/tom\/documents\/pdfs\//<new text>/g


I am, in general, drawn to tools that are both practical and cleave to an aesthetic. Maybe it’s a fetish, plain and simple, and I have no business trying to promote a personal preference. But vim is in there.

Leave a Reply

Your email address will not be published. Required fields are marked *