Vim: Find and replace in a large project?

There is a way to replace all cases of a string in files in Vim using a combination of the args and argdo commands . Unfortunately, there is a drawback to this solution: it will open all files that may be a problem for large projects. Does anyone know a more compact and efficient way of memory?

+5
source share
2 answers
find projectfolder -type f -exec grep -Iq 'pattern' {} \; -exec vim {} +
+6
source

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 ask for confirmation for each lookup.

+3
source

All Articles