Last Updated: February 25, 2016
· karthiks

Vim: Find and Replace text across files

Step 1: Load files to vim buffer with command below wherein files under say, 'app/' needs to be searched for search-text:

:args  app/

Step 2: Find, and replace text. And save modified files too. The command below does that:

:argdo %s/<search_text>/<new_replacing_text>/gec | update

4 Responses
Add your response

I'm getting an error "Cannot make changes, 'modifiable' is off". Have you ran into this?

over 1 year ago ·


:set modifiable
over 1 year ago ·

@vimrocks Thanks. I have that set in my .vimrc but I still get the error

over 1 year ago ·

actually, figured it out. I did :args directoryname/* to get files into buffer instead of just the directory and then it worked. thanks!

over 1 year ago ·