Removing text from all files in a directory using Vim
When I'm working on a feature in Ruby/Rspec project, I'll commonly add :focus
symbols to my specs.
This is great until I'm ready to merge in and I've forgotten where I put all the :focus
symbols.
I hate the thought of going through each test file by hand and doing a search/replace, so I dug on the interwebs to see if there's a way to programmatically remove text from all files in a directory.
Luckily, there is.:)
- Open vim
-
:args parent/directory/**/*.rb
. This recursively opens.rb
all files under parent/directory. -
:bufdo %s/find_this/replace_with_this/g |w
. This does a search/replace on each open file, then saves it.
I found this at stackoverflow
Written by David Weiser
Related protips
1 Response
Another alternative:
sed -i 's/find_this/replace_with_this/g'
parent/directory/*/.rb
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Related Tags
#vim
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#