How to edit latex-generated text in Captions?

I want to take the answer to the question LaTeX source code listing like in professional books one step further, and change the (latex-generated) text in the caption from Listing n to something more personalized, like Code Snippet n.

How can I do this?

-

migrated from stackoverflow.comJun 4 '12 at 7:56

This question came from our site for professional and enthusiast programmers.

Okay. How can I migrate this question? Or should I repost? –  SNag Jun 3 '12 at 20:34
You can flag it for attention by a moderator, and ask them to migrate it. –  Makoto Jun 3 '12 at 20:36
Makoto is right, it is described in this meta question –  buc Jun 3 '12 at 20:39

You can use \renewcommand* to change the value from Listing to whatever you wish.

\usepackage{listings}
\begin{document}
Some dummy text.

\renewcommand*\lstlistingname{Example}
% Some helpers that made C code look passable in a report
\begin{lstlisting}[caption={C code},label=C, language=C, basicstyle=\ttfamily, keywordstyle=\normalsize, identifierstyle=\normalsize, stringstyle=\normalsize, showstringspaces=false]

for (j = 0; j < 20; ++j) {
while ((c = getchar()) != '-') {
printf("j=%d\n", j);
if (c == ' ' || c == '\t' || c == '\n')
++j;
else
length[j]++;
}
}
\end{lstlisting}
\end{document}

-
Thanks Makoto! This is what I was looking for! –  SNag Jun 3 '12 at 20:48
@SNag: I don't think there is any (tested it out when you asked the question). It's the command that appeared in some of my old printoffs about TeX, and that's the one manual I had to grab when I answered this. –  Makoto Jun 5 '12 at 23:58