# How to change listing caption?

I have some listings that contain pseudo-code of algorithms. And I use this: \lstset{caption={Descriptive Caption Text},label=DescriptiveLabel} to add captions to them.

My problem is that the caption at the created file shows Listing 1: Descriptive Caption Text. I would like it to write something like Algorithm 1: Descriptive Caption Text.

How can this be done?

The following modifications are what you're after:

\renewcommand{\lstlistingname}{Algorithm}% Listing -> Algorithm
\renewcommand{\lstlistlistingname}{List of \lstlistingname s}% List of Listings -> List of Algorithms

\documentclass{article}
\usepackage{listings}% http://ctan.org/pkg/listings
\renewcommand{\lstlistingname}{Algorithm}% Listing -> Algorithm
\renewcommand{\lstlistlistingname}{List of \lstlistingname s}% List of Listings -> List of Algorithms
\begin{document}
\lstlistoflistings

\begin{lstlisting}[caption={Descriptive Caption Text},label=DescriptiveLabel]
for i:=maxint to 0 do
begin
{ do nothing }
end;
Write('Case insensitive ');
WritE('Pascal keywords.');
\end{lstlisting}

\end{document}​

The example was taken directly from the listings documentation.

If you want to change the lstlistings name in between for one listing and rename it back. Just renewcommand multiple times e.g.,

\renewcommand{\lstlistingname}{Code} % Listing->Code
\begin{lstlisting}[caption={Example of Code}
B0:
b = m
c = n
if p is true then goto B1 else goto B2
B1:
a0 = b
goto B3
B2:
a1 = b
goto B3
\end{lstlisting}
\renewcommand{\lstlistingname}{Algorithm}. % Code to Algorithm