Emacs & Vim don't seem to have the capability. But fortunately, Unix commandline can do it decently, though there's no good "undo" operation.
the find command is key. Something like this will get your list of files to operate on:
find -name '*.php' -not -path '*/obsolete/*'To diagnose where something is:
find -name '*.php' -not -path '*/obsolete/*' | xargs grep OLD_VAR_NAME find -name '*.php' -not -path '*/obsolete/*' | xargs grep -n OLD_VAR_NAME find -name '*.php' -not -path '*/obsolete/*' | xargs grep -l OLD_VAR_NAME
INTERACTIVELY FIND AND REPLACE
Inside emacs, do M-x grep and then run that with grep's -n switch for line numbers:
find... | xargs grep -n OLD_VAR_NAME...this gets you a list of matches. middle-clicking on one brings you to the match at that file... from where you can manually edit each match, or rerun M-Ctrl-Shift-X (regex find/replace) many times. crappy but better than without grepping.
AUTOMATIC FIND AND REPLACE
For automatic replacement, you want to use perl -pi.bak -e to do replacements on all files in place. [warning: this doesn't play nicely with symlinked files, it creates new non-symlinked copies of them]
find... | xargs perl -pi.bak -e 's/OLD_VAR_NAME/NEW_VAR_NAME/g'make sure to use .bak1, .bak2, etc.
Using funny characters like > and ; can be confusing, since you're dealing with both shell and perl regex escaping rules. To test things without making a hard-to-undo destructive change, just don't use the -i command, then you'll merely see the resulting changed files.
find... | xargs perl -pe 's/OLD_VAR_NAME/NEW_VAR_NAME/g' find... | xargs perl -pe 's/OLD_VAR_NAME/NEW_VAR_NAME/g' | grep NEW_VAR_NAMEAs far as weird interaction of escaping rules goes: you should always use bash's single quotes for the perl expression. but what it you want to use single quotes inside the expression? If you put quoted strings next to each other in bash, they are concatted together as one argument. So the best way is to concat a double-quoted single-quote in the middle of the string. observe:
$ echo 'deme'"'"'s data directory' deme's data directory
Furthermore. If you get lots of .bak, .bak1's piling up, do a
mkdir bak find -name '*.bak' | xargs mv --dest bak
......and for all of these things, the up and down arrows [or ctrl-p, ctrl-n in emacs] are indispensable, since usually all you want to do is change the next command in the pipeline; the same find command you'll use for all of these operations, for example.
Resources:
Data Recovery Company
Best Nose Hair Trimmer
Mobility Chairs
Komodo Island is the NEW 7 Wonders of The World
PPI Reclaim
Vacuum Cleaners Special Offers
proactol plus
