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
Written by Karthik Sirasanagandla
Related protips
4 Responses
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/44996/3ae6de27bfeb80acbecc2587763750d9.png)
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
·
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/44996/3ae6de27bfeb80acbecc2587763750d9.png)
@vimrocks Thanks. I have that set in my .vimrc but I still get the error
over 1 year ago
·
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/44996/3ae6de27bfeb80acbecc2587763750d9.png)
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
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#