# Listings: Replace the left out code

Is it possible to leave out some code and mark this, instead of including only parts of the code (which is almost the same)?

I would like to have an output almost like the second and third listing in combination. The vertical lines (between the two listings) might be dotted or dashed or be crossed out by two short lines. Also instead of ... there might be an other "replacement text/symbol"

Does the package contain something like this? Or can it be achieved (easily)?

\documentclass{article}

\usepackage{listings}

\begin{document}

whole code in \texttt{filepath}:
\begin{lstlisting}[numbers=left,frame=single,language=pascal]
for i:=maxint to 0 do
begin
very
much
code
end;

Write(Case insensitive);
WritE(Pascal keywords.);
\end{lstlisting}

%real usage:
%\lstinputlisting[firstnumber=1,linerange={1-2,6-9}]{filepath}

\vspace{5cm}

%almost desired output
\begin{lstlisting}[numbers=left,frame=tlr,language=pascal]
for i:=maxint to 0 do
begin
\end{lstlisting}...
\begin{lstlisting}[firstnumber=6,numbers=left,frame=blr,language=pascal]
end;

Write(Case insensitive);
WritE(Pascal keywords.);
\end{lstlisting}

\end{document}


I did something similar in my thesis (appendix). I deliberately broke the listing where I omitted code, and put an explanation in normal text. Otherwise it would have looked like the ellipsis was part of the code. Note that the code was set very tight, vertically and horizontally (latin modern tt condensed).

    The Python code set out in this section was written for finding the peaks from the \mbox{GaN} and \AlGaN{x} epilayers of the devices studied in \rep{Chapter}{chapter}~\ref{chap_IMEC}.
It was also used to find the positions of both Raman and \acl{PL} peaks in some of the other results in this thesis.
\setstretch{.9}%
\lstset{firstnumber=auto}%
\lstinputlisting[caption={},linerange={1-73}]{Appendices/PeakPick.py}%
\vspace{-1.3\baselineskip}{\footnotesize $\scriptstyle\vdots\quad$ The setup routine writes a default configuration file.}\vspace{-.3\baselineskip}
\lstinputlisting[caption={},firstnumber=118,firstline=118,lastline=377]{Appendices/PeakPick.py}%
\vspace{-1.3\baselineskip}{\footnotesize $\scriptstyle\vdots\quad$ User options are read from the command line and configuration file.}\vspace{-.3\baselineskip}
\lstinputlisting[caption={},firstnumber=431,linerange={431-514}]{Appendices/PeakPick.py}%
\vspace{-0.5\baselineskip}%

• Out of time to insert an image but I'll try to add it later, with more details – Chris H Mar 25 at 17:00

I guess, that there is no build in feature, because until now, no one came up with it.

Taking Chris H's answer, I got: (I think, that this can be done better, so everyone feel free to provide suggestions)

\documentclass{article}

\usepackage{listings}
\usepackage{tikz}

\lstset{numbers=left}

\begin{document}

text
\lstinputlisting[belowskip=0pt,frame=tlr,linerange={1-3}]{filepath}%
\hspace{-3.4pt}\begin{tikzpicture}
\draw[dotted] (0,0)-- (0,1.1em);
\end{tikzpicture} \hspace{\linewidth}\hspace{1.7pt}
\begin{tikzpicture}
\draw[dotted] (0,0) -- (0,1.1em);
\end{tikzpicture}
\lstinputlisting[aboveskip=0pt,belowskip=0pt,frame=lr,firstnumber=7,firstline=7,lastline=17]{filepath}%
\hspace{-3.4pt}\begin{tikzpicture}
\draw[dotted] (0,0)-- (0,1.1em);
\end{tikzpicture} \hspace{\linewidth}\hspace{1.7pt}
\begin{tikzpicture}
\draw[dotted] (0,0) -- (0,1.1em);
\end{tikzpicture}
\lstinputlisting[aboveskip=0pt,frame=blr,firstnumber=20,linerange={20-22}]{filepath}%
text

\end{document}