I can add that @VZ.'s solution also works if you want to "single-step" some code (in my case, C code with pointers) together with illustrations using tikzpicture. The "obvious" solution did not work, neither did using escapeinside due to a bug in pygments (see https://github.com/gpoore/minted/issues/70). In the solution below, highlightlines is used to highlight the current instruction. Too bad the actual C code need to be duplicate - but hey, it works!
\documentclass{beamer}
\usepackage{minted}
\usepackage{tikz}
\begin{document}
\begin{frame}[fragile]
\frametitle{Foo}
\begin{overprint}
\onslide<1>
\begin{minted}[linenos,highlightlines={3}]{c}
int main(void) {
char *p;
p=(char *)malloc(5);
/* do stuff */
p=(char *)malloc(7);
free(p);
return 0;
}
\end{minted}
\onslide<2>
\begin{minted}[linenos,highlightlines={5}]{c}
int main(void) {
char *p;
p=(char *)malloc(5);
/* do stuff */
p=(char *)malloc(7);
free(p);
return 0;
}
\end{minted}
\end{overprint}
\begin{tikzpicture}
\node<1->[rectangle,draw] (p) {p};
\node<1->[rectangle,draw,right of=p] (q1) {q1};
\draw<1>[->] (p) -- (q1);
\uncover<2->{\node[rectangle,draw,below right of=p] (q2) {q2};};
\draw<2->[->] (p) -- (q2);
\end{tikzpicture}
\end{frame}
\end{document}
overprintdo? – khatchad Jul 01 '20 at 18:16