There's a way to replace all occurencies of a string in files in Vim using a combination of args and argdo commands. Unfortunately there's a drawback with this solution: It will open all files which may be a problem for large projects. Does anyone know more compact and memory efficient way?
find projectfolder -type f -exec grep -Iq 'pattern' {} \; -exec vim {} +
Here's how I do it (when I'm not using perl
):
find . -name '*.java' -exec vim +'%s/OldName/NewName/gc' +'wq' {} \;
i.e. replace "OldName" with "NewName" in all "*.java" files, but prompt me for confirmation for each substitution.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With