For editing code:
You have vi installed already (like vim without all the cool stuff) as well as a terminal version of emacs. The Cocoa version of emacs looks beatiful on OS X. I'm not sure if there's a gvim port.
For installing software:
I've heard good things about
fink for installing Free software.