How to correct a command in bash
Magnificent app which corrects your previous console command
In my mac I install it by command 'sudo pip install thefuck'. More info in project's git: https://github.com/nvbn/thefuck
BTW try to press Ctrl-X Ctrl-E in bash command line to switch the editing in your editor. And specify the editor using EDITOR env variable.