Apple - Change the default text editor in Terminal
Simply set the EDITOR
variable to vim
in your bash startup file.
EDITOR=vim
From the bash
manual
edit-and-execute-command (C-xC-e)
Invoke an editor on the current command line, and execute the result as shell commands. Bash
attempts to invoke $FCEDIT, $EDITOR, and emacs as the editor, in that order.
I prefer using fc
since that's my Korn shell (ksh) to get to my editor and that should choose vim
by default since they go together more naturally than the emacs
command.
For changing the editor, I usually set FCEDIT so that it catches both the bash / emacs invocation for the fc
built in commands. I rarely change things, though since it's nice to know I can get directly to emacs when needed (on occasion it's better for me) and let fc
do the heavy lifting for me. Great question!