# Renewenvironment verbatim as lstlisting

I am using pandoc to convert some HTML into LaTeX. pandoc converts code (<pre>) into verbatim, which does not handle line breaks.

As I found on this website, the recommended solution is to switch to lstlisting, however I'm not really fan of modifying pandoc for that, so I thought I would just replace the verbatim environment to lstlisting, which I fully configured with lstset in my document.

I tried, and I failed.

Here is my simple attempt:

\renewenvironment{verbatim}{\begin{lstlisting}}{\end{lstlisting}}


which produces this error:

Emergency stop. No legal \end found

You should use \lstnewenvironment to define new listings environments. As it is only for new environments you must first undefine verbatim:

\documentclass[]{article}
\usepackage{listings}

\begin{document}

\begin{verbatim}
\section{}
\end{verbatim}

\let\verbatim\someundefinedcommand
\lstnewenvironment{verbatim}
{}{}

\begin{verbatim}
\section{}
\end{verbatim}

\end{document}