To make it permanent simply do the following in terminal:
echo "export EDITOR=vi" >> ~/.bashrc
This will add the line to your .bashrc
file which gets called every time you open a terminal window.
To answer why this will work even if there has been a similar line before added to .bashrc
is simple. .bashrc
is a script with will be read and executed in a linear way, and this method is adding this line as the last below all others, so it gets executed/evaluated as last. So if there has been a line before the value of the EDITOR
variable will be overwritten by the line you add.
Alternatively, if you not want to create a mess you can as well using your favorite editor (vi, vim, nano, joe etc..) to do this change and add a line if none is present and if one is present edit it.
/home/$USER/.bashrc
file