Can I replace all instances of one string expressions in the TeX files in one directory?
For example, let's say I want to replace all \frac with \myfrac in more than one file simultaneously.
|
Can I replace all instances of one string expressions in the For example, let's say I want to replace all |
||||
|
Which operating system are you using? If you're using a *nix based operating system (Mac included), it's probably easiest to do this out of TeX, in the command line / terminal:
(using a combination of So you'd need:
Hope this helps. |
|||||||||||||
|
|
If you use Vim, you can try the following: First open one of your .tex files in vim. Load the other .tex files from the same directory by opening them in hidden buffers:
Now all the *.tex files in the directory are loaded into (hidden) buffers. You can apply a standard substitution command to each of these files by issuing the following command:
The % is the range (entire file), s denotes the substitution command, string1 is found and replaced by string2 on each line, and g indicates that this is done globally (so not just the first instance on each line). The last part | update will automatically save all the files after the substitution is complete. Because the backslash is a "special" character, you need to escape it with another backslash. In your case, you would issue the command:
|
|||
|
|
|
Most advanced text editors have a For example, Notepad++ on Windows provides this feature. As mentionned in another response to this question, if you are using a *nix-based system, you could quite easily use the command line. |
|||
|
|
\frac{}{}and use\let\OldFrac\frac, and\let\frac\myfrac. And if\myfracwas originally usingfrac, replace the occurrence offracwithOldFracwithin the definition of\myfrac. – Peter Grill May 4 '12 at 14:59