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
- Highlighting the matches
- An overview of the highlighted results all together in a manageable layout (similar to the log view of
Magitin Emacs when you press
lfollowed by another
lor simply like
C-x din 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:
- Dired mode
% gwill mark all files containing that regexp. Cons: this will include even file unrelated to the project including non .tex files.
C-x 3opens 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
% mwithin Dired-mode by regexp in order to mark only
.texfiles so basically running
\.texwill get me there.
C-x 3same as above to keep one buffer for overview and the other for query
Qwithin Dired which is query replace regexp in marked files only. Alternatively
Ais 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?
- Emacs 24.4 on Windows 7