The following LaTeX manuscript
\documentclass{article}
\usepackage{xparse,minted}
\NewDocumentEnvironment{MyMinted}{}
{\begin{minted}[escapeinside=||,mathescape=true]{c}}
{\end{minted}}
\begin{document}
\begin{MyMinted}
double diff(double (*f)(double), double |$x_0$|) {
return |$\frac{d(*f)}{dx}(x_0)$|;
}
\end{MyMinted}
\end{document}
produces (upon compilation with pdflatex -shell-escape) the following error message:
Runaway argument?
! File ended while scanning use of \FancyVerbGetLine.
<inserted text>
\par
What's the problem, and how can I fix it?

\newmintedcommand to create a new environment, not \newenvironment or something similar. See section "Defining shortcuts" in the docu. – Ulrike Fischer Nov 07 '17 at 11:46\does not start a tex command it is just a literal character so\end{MyMinted}does not end the environment, minted is looking for the literal string\end{minted}– David Carlisle Nov 07 '17 at 11:48\newminted? I see none. Use\newminted[MyMinted]{c}{escapeinside=||,mathescape=true}– egreg Nov 07 '17 at 12:53