I am about to adopt Emacs to be the only editor I use in all what I am writing including LaTeX documents. I came from WYSIWYG editor which served that purpose fairly nice, namely TexStudio or TXS for short. For the transition from TXS to Emacs I am still missing the way TXS deals with executing massive regexp query search & replace with highlighting the matches and restriction of the search to only those project-related .tex
files. I deeply miss that in Emacs now. See a screenshot of TXS below:
TeXStudio Query in a Multifile LaTeX Project
I would like to emphasize the points in the workflow to be achieved in Emacs:
- RegExp Query Search and Replacement only in the project-related
.tex
files. - Highlighting the matches
- An overview of the highlighted results all together in a manageable layout (similar to the log view of
Magit
in Emacs when you pressl
followed by anotherl
or simply likeC-x d
in Dired mode - How to know how much replacement or inspection matches done with or remaining and a way to resume query in case it is broken by a clumsy keystroke that stops the query
- A clean way out of this messy query by closing and saving all related files and back to the state before invoking this query
I read this post but my intention is to be more like CW
that anyone can share his best workflow to get this common job done. My current approach(es) as follows:
First Workflow
- Dired mode
% g
will mark all files containing that regexp. Cons: this will include even file unrelated to the project including non .tex files. C-x 3
opens a new buffer while keeping an eye on the first buffer as my orientation overview of what marked files I have to query in the new buffer individually- Running the query by
C-c q
. It has very nice switches like!
replace all without asking plus highlighting matches within the opened file. But this means I have to run the same query each time and for every marked file. - After doing all marked files I hit
C-x s !
to save all in one keystroke. Phew!
Second Workflow -- preferred
- Marking all
.tex
files using% m
within Dired-mode by regexp in order to mark only.tex
files so basically running\.tex
will get me there. C-x 3
same as above to keep one buffer for overview and the other for query- Executing
Q
within Dired which is query replace regexp in marked files only. AlternativelyA
is only regexp search query. A full-fledged query will be executed and a help menu by?
is generously provided C-x s !
save and close all the mess. Otherwise I had to close the opened files one by one which is tedious. I hope there is a way to close only those we bothered.
How do I approximate TXS's regexp search/replace query in multifiles?
Note
- Emacs 24.4 on Windows 7