mqvdlq
Last Updated: February 25, 2016
·
1.492K
· karthiks
Just my back

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
Say Thanks
Respond

4 Responses
Add your response

1412
3ae6de27bfeb80acbecc2587763750d9

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

over 1 year ago ·
1425

@design48

:set modifiable
over 1 year ago ·
1427
3ae6de27bfeb80acbecc2587763750d9

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

over 1 year ago ·
1428
3ae6de27bfeb80acbecc2587763750d9

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 ·
Filed Under