# How to make tabsize also affect lstinputlisting?

I noticed that tabsize only affects lstlisting and lstinline macros.

Here is the output. The top figure is displayed using lstinputlisting and the bottom one is displayed using lstlisting. The tabsize does not affect the top one. But it does for the bottom one.

How to make it works for all macros?

\documentclass[dvips,dvipsnames,rgb,table]{article}
\usepackage[a4paper,hmargin=20mm,vmargin=20mm]{geometry}
\usepackage{xcolor}

\usepackage{listings}
\lstset%
{%
literate={ï}{}0
{»}{}0
{¿}{}0,
language={[Sharp]C},
breaklines=true,
breakindent=0pt,
tabsize=2,
basicstyle=\color{White}\ttfamily\scriptsize,
keywordstyle=\color{Orange}\sffamily\bfseries,
stringstyle=\color{Cyan}\rmfamily,
showstringspaces=true,
aboveskip=0pt,
belowskip=0pt,
backgroundcolor=\color{Black}%,
%rangeprefix=\%,
%rangesuffix=\%,
%includerangemarker=false,
%linerange=start-stop%
}

\usepackage{fancyvrb}
\def\MyOwn%
{%
\VerbatimEnvironment%
\begin{VerbatimOut}{\jobname.tmp}%
}
\def\endMyOwn%
{%
\end{VerbatimOut}%
\lstinputlisting{\jobname.tmp}%
}

\begin{document}
\begin{MyOwn}
using System;
class Foo
{
void Main()
{
Console.WriteLine("using lstinputlisting");
}
}
\end{MyOwn}

\vspace{1cm}

\begin{lstlisting}
using System;
class Foo
{
void Main()
{
Console.WriteLine("using lstlisting");
}
}
\end{lstlisting}
\end{document}


Does the \VerbatimEnvironment cause this problem?

-
Look at the output file, does it contain tabs? If not, then tabsize doesn't do anything. –  TH. Jan 4 '11 at 5:51

use also:

\usepackage{fancyvrb}
\fvset{tabsize=2}

-
thanks. It works now. :-) –  xport Jan 4 '11 at 7:41
Could you please post the full code? I can't get it to work. Thanks. –  Jubobs Mar 14 '14 at 19:54
I suppose that you do not have tabs but spaces instead. –  Herbert Mar 15 '14 at 6:49