|
|
|
|
|
by mixedmath
3979 days ago
|
|
For what it's worth, the author (sankho) mentions that he uses other editors for project-wide find and replace. This can be done in vim too (although I do not --- I'll return to this). You can check out the typically great vimcasts post on this: http://vimcasts.org/episodes/project-wide-find-and-replace/ For whatever reason, I find it easier to use commandline tools to do large search and replaces. I do embrace the vim-as-text-editor within the larger Linux-program-composability philosophy, but I understand that not everyone else does. So I use ack and perl, as mentioned in this StackOverflow post:
http://stackoverflow.com/a/8744108/1141805 (Actually, sometimes I distinctly do things the wrong way. I open a scratch buffer, `:r! ls` to get my file names, restrict to those that I want, create a macro that does what I want on the file under the cursor, and then repeat the macro. I am not proud.) |
|
It uses Ag to search over each file and Perl to perform the necessary regex. It also creates *.bak backup files in case I replaced something that wasn't supposed to be replaced, but will remove those backup files if I'm in a Git repo (because I basically had to `git clean -f` every time after using this command...so I just wrote it into the command)