typing \end{verbatim}

You can create a new environment that ensembles the verbatim environment, like:

\documentclass{article}
\usepackage{verbatim}
\newenvironment{realverbatim}{\verbatim}{\endverbatim}

\begin{document}
Test of the new \verb~verbatim~ environment:

\begin{realverbatim}
\begin{verbatim}
foo
\end{verbatim}
\end{realverbatim}

\end{document}

Try

\usepackage{verbatim}
\verb+\begin{verbatim} foo \end{verbatim}+

or, if you want it on separate lines

\verb+\begin{verbatim}+\\
\verb+foo+\\
\verb+\end{verbatim}+

or, if foo is long,

\verb+\begin{verbatim}+
\begin{verbatim}
foo
\end{verbatim}
\verb+\end{verbatim}+

I don't think that there is any really sensible trick which will work with verbatim directly. I would use another verbatim-like environment from the listings or the fancyvrb package.

Tags:

Verbatim