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.
This question gets to the root of how you want to work - so there's some "preference" that may be in play. If you come from the school of vi
you might prefer a command as opposed to the emacs key bindings.
I prefer using fc
since my big chunk of time post-emacs was spent in Korn shell (ksh) and I used fc
built in to summon the editor. On all macOS systems, by default vim
is chosen over 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. So if I were to head back to “emacs land”, fc
is how I'd get there initially.