Substituting character $l$ with $\ell$ throughout math mode
This is similar to how MinionPro
deals with open vs closed mathematical g's.
\documentclass{article}
\mathcode`l="8000
\begingroup
\makeatletter
\lccode`\~=`\l
\DeclareMathSymbol{\lsb@l}{\mathalpha}{letters}{`l}
\lowercase{\gdef~{\ifnum\the\mathgroup=\m@ne \ell \else \lsb@l \fi}}%
\endgroup
\begin{document}
\( l = 2 \) \( \lim = 2 \)
\end{document}
There is if you are using Lyx or SWP. E.g., you can have SWP search for l in math (SWP is wysiwym) and replace it with \ell. It will do this and ignore l in text.
To do it via an external search-and-replace, you could use a script that I wrote called mathgrep. It's a perl script designed to do search and search-and-replace within maths sections of a LaTeX document.
The main limitation of this script is that it doesn't regard dollars as valid maths delimiters - but then, no-one uses them, right? Actually, I wrote a script to deal with that as well, which I called debuck for some reason that escapes me now.
(Oh yeah, I remember: dollar = buck.)