How to define a command with lstlist code as argument

I want to implement a command like these:

\documentclass[]{standalone}

\newcommand{\oneCode}[1]{
\begin{lstlisting}
#1
\end{lstlisting}
}

\begin{document}

\oneCode{#$duihnlv/} \end{document}  It seems, that lstlisting interpretes the argument #1 as code not as argument. How to force lstlisting to take #1 as argument? • Why would you want to do that? Use the commands provided by listings to create new envrionments or inline commands. Your command currently looks like \lstinline. – TeXnician May 29 '18 at 8:07 • It becomes more complex later on. This is only the example for this question. – Alex44 May 29 '18 at 8:08 • you can not, in general, use any verbatim command (including listings) in the argument of another command. – David Carlisle May 29 '18 at 8:10 • Could you please explain at which point the commands provided by listings aren't sufficient? – TeXnician May 29 '18 at 8:11 • There is nothing insufficient. It is only for formatting / pre-defining minipages. There are some hundreds code snippets which shall displayed always in the same format. – Alex44 May 29 '18 at 8:14 1 Answer You can define new inline versions of \lstinline like this. The important point is not to use a (mandatory) argument so that \lstinline can do its own magic. \documentclass[]{standalone} \usepackage{listings,xcolor} \newcommand\oneCode{\lstinline[basicstyle=\color{green}\sffamily]} \begin{document} \oneCode{#$duihnlv/}

\end{document}