====== History Expansion ======
==== ^foo^bar ====
To retrieve the last command replacing a certain pattern once:
% mv foo.c old/ # very silly example, I know...
% ^foo^bar
% mv bar.c old/
However if you need to replace all occurences, with zsh 4.3.1 you can use:
% mv foo.c foo_archive
% ^foo^bar:G
% mv bar.c bar_archive
Another way to achieve the same global substitution is to use:
% r foo=bar
There's **lot's** of stuff to be done with substitution on history, read the section "HISTORY EXPANSION" on zsh's manual to learn more.