答案1
您可以使用一个钩子:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{listings}
\begin{document}
\begin{lstlisting}
abc
abc
abc
\end{lstlisting}
\makeatletter
\lst@AddToHook{OnEmptyLine}{\vspace{-0.7\baselineskip}}
\makeatother
\begin{lstlisting}
abc
abc
abc
\end{lstlisting}
\end{document}