# Can you change lstinline without changing the global lstset?

Consider that I want to be able to write:

\inline{some code or keyword} and just have it distinguished from the rest of the paragraph text, I've done that like this:

\def\inline{\lstinline[basicstyle=\ttfamily]}


However, if you have a custom \lstset that sets for instance keywordstyle, this will be used for the inlining as well! Is there a way to remove that? Is it possible to use something like \lstnewenvironment to accomplish it?

-

You can override keywordstyle on a case-by-case basis in \lstinline:

\documentclass{article}
\usepackage{listings,xcolor}
\lstset{keywordstyle=\sffamily\color{red},language=C}
\def\inline{\lstinline[basicstyle=\ttfamily,keywordstyle={}]}

\begin{document}
Compare \lstinline|int a=3;| with red sans-serif keywords to
\inline{int a=3;} where keywords inherit from basicstyle.
\end{document}


-
Very nice! How about if you have more keywordstyles, this wont work: \def\inline{\lstinline[basicstyle=\ttfamily,keywordstyle={},keywordstyle=[1]{}]‌​}. Then is when I've defined morekeywords. –  Filip Ekberg Feb 16 '12 at 6:40