# Skip line numbers and resume from specific number in Minted?

This question has already been asked for the package listings, but I am using minted and want to achieve the same thing.

My document looks as follows:

\documentclass{article}
\usepackage{minted}

\begin{document}

\begin{minted}[breaklines=true,linenos]{javascript}
/* My Code: */

console.log("Hello");

console.log("World");
console.log("FooBar");

console.log("BarFoo");
console.log("FooFoo");

\end{minted}

\end{document}


This gives me the following output:

However, I want to have the following result:

1  | /* My Code: */
...|
128| console.log("Hello");
...|
188| console.log("World");
189| console.log("FooBar");
...|
201| console.log("BarFoo");
202| console.log("FooFoo");


How can this be done?

\documentclass{article}
\usepackage{minted}

\begin{document}

\renewcommand\theFancyVerbLine{%
\ifnum\value{FancyVerbLine}=2
\setcounter{FancyVerbLine}{127}\ldots
\else\ifnum\value{FancyVerbLine}=129
\setcounter{FancyVerbLine}{187}\ldots
\else\ifnum\value{FancyVerbLine}=190
\setcounter{FancyVerbLine}{200}\ldots
\else
\arabic{FancyVerbLine}%
\fi
\fi
\fi
}
\begin{minted}[breaklines=true,linenos]{javascript}
/* My Code: */

console.log("Hello");

console.log("World");
console.log("FooBar");

console.log("BarFoo");
console.log("FooFoo");

\end{minted}

\end{document}

• Thank you! This works for perfectly, but now all of my other code snippets also have that numbering. How can I reset it or limit it to one specific minted? Jul 19, 2017 at 15:49
• @JohnDoe yes the definition of \theFancyVerbLine is local so you can do it inside any existing group (eg if this is in figure or just surround by { ..renewcommand...begin minted ...end minted ...} so it is restored at the } Jul 19, 2017 at 15:58
• What an ugly hack. I love it :-)
– bp99
Oct 24, 2021 at 20:58
• @bp99 I believe you have a typo and you intended to write "brilliantly engineered solution" Oct 24, 2021 at 21:17