# lstlistings with with different languages and diffrent keywords

``````\lstdefinelanguage{RIPE}
{%
sensitive=t,%
morekeywords={inetnum, netname,descr, country, admin-c, tech-c, status, mnt-by, notify, created, %
last-modified, source, person, address, phone, e-mail, nic-hdl, notify, route, descr, origin, member-of},
}

\lstset{
language=RIPE,
alsoletter={-},
backgroundcolor = \color{lightgray},
basicstyle=\small\ttfamily, % Global Code Style
captionpos=b, % Position of the Caption (t for top, b for bottom)
extendedchars=true, % Allows 256 instead of 128 ASCII characters
tabsize=2, % number of spaces indented when discovering a tab
columns=fixed, % make all characters equal width
keepspaces=true, % does not ignore spaces to fit width, convert tabs to spaces
showstringspaces=false, % lets spaces in strings appear as real spaces
breaklines=true, % wrap lines if they don't fit
frame=trbl, % draw a frame at the top, right, left and bottom of the listing
frameround=tttt, % make the frame round at all four corners
framesep=4pt, % quarter circle size of the round corners
%numbers=left, % show line numbers at the left
%numberstyle=\tiny\ttfamily, % style of the line numbers
keywordstyle=\bfseries\color{red}, % style of keywords
stringstyle=\color{eclipseBlue}, % style of strings
}

\lstdefinelanguage{nmap}
{%
sensitive=t,%
morekeywords={nmap, Host, PORT, STATE, SERVICE,VERSION, open, closed, filtered, up, down},
}

\lstset{
language={nmap},
alsoletter={-},
backgroundcolor = \color{lightgray},
basicstyle=\small\ttfamily, % Global Code Style
captionpos=b, % Position of the Caption (t for top, b for bottom)
extendedchars=true, % Allows 256 instead of 128 ASCII characters
tabsize=2, % number of spaces indented when discovering a tab
columns=fixed, % make all characters equal width
keepspaces=true, % does not ignore spaces to fit width, convert tabs to spaces
showstringspaces=false, % lets spaces in strings appear as real spaces
breaklines=true, % wrap lines if they don't fit
frame=trbl, % draw a frame at the top, right, left and bottom of the listing
frameround=tttt, % make the frame round at all four corners
framesep=4pt, % quarter circle size of the round corners
%numbers=left, % show line numbers at the left
%numberstyle=\tiny\ttfamily, % style of the line numbers
keywordstyle=\bfseries\color{red}, % style of keywords
stringstyle=\color{eclipseBlue}, % style of strings
}
``````

For some Reason it doesn't work. Then I make a lstlisting and use nmap for language everything is ok but if I use RIPE for language, there are no colors.

I switched both blocks and it seems that just the last one defined is in use. Any solutions?

• You want to define two separate environments, not overwrite the styling with `\lstset`, don't you? – TeXnician Apr 26 at 14:02