How to change the default editor in Terminal

In the terminal, run

export EDITOR=nano

to change the default editor to nano (or whatever) and then run

source ~/.bashrc

for the change to take effect