That line is just an artifact of the viewer.
Declare an invisible frame
to the left (and to the right) and use the desired value for framesep
.
An example:
\documentclass{article}
\usepackage{listings}
\usepackage{color}
\begin{document}
\definecolor{light-gray}{gray}{0.95}
\lstset{columns=fullflexible, basicstyle=\ttfamily,
backgroundcolor=\color{light-gray},xleftmargin=0.5cm,frame=lr,framesep=8pt,framerule=0pt}
\begin{lstlisting}
Test code
\\ a bit of comments
\end{lstlisting}
\end{document}
Using a frame in the four sides:
\documentclass{article}
\usepackage{listings}
\usepackage{color}
\begin{document}
\definecolor{light-gray}{gray}{0.95}
\lstset{columns=fullflexible, basicstyle=\ttfamily,
backgroundcolor=\color{light-gray},xleftmargin=0.5cm,frame=tlbr,framesep=4pt,framerule=0pt}
\begin{lstlisting}
Test code
\\ a bit of comments
\end{lstlisting}
\end{document}
To have control over the separation on each side independently, you can use the mdframed
package to surround lstlisting
with a frame with the desired specifications:
\documentclass{article}
\usepackage{listings}
\usepackage{color}
\usepackage[framemethod=tikz]{mdframed}
\definecolor{light-gray}{gray}{0.95}
\lstset{columns=fullflexible,basicstyle=\ttfamily}
\surroundwithmdframed[
hidealllines=true,
backgroundcolor=light-gray,
innerleftmargin=15pt,
innertopmargin=0pt,
innerbottommargin=0pt]{lstlisting}
\begin{document}
\begin{lstlisting}
Test code
\\ a bit of comments
\end{lstlisting}
\end{document}