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
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
·
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#