I know this is likely a simple Latex macro question. I've got a large document with a ton of lstlisting
blocks, and I'd like to use minted
instead.
That means turning blocks that look like this:
\begin{lstlisting}
...code...
\end{lstlisting}
Into something that looks like this:
\begin{minted}{scala}
...code...
\end{minted}
I know I can do a find/replace but want an excuse to figure out how to write some of my own LaTeX macros :)
Any suggestions on how to achieve this?
sed
, then -- basic tool in the kit:sed 's/{lstlsting}/{minted}{scala}/' file.tex > minted-test.tex
. Make a backup though, just in case -- I haven't tested that command. What Joseph means is that verbatim environments (like{lstlisting}
and{minted}
) look for exactly the text\end{lstlisting}
(or\end{minted}
) to stop the environment. The normal way environments are ended is a bit simpler, so making it a macro isn't a problem. Something like this though would be much more involved, if not infeasible.