Nowadays Linux uses nano for most distributions as the default text editor. In some cases people prefer that, but others may not. It’s possible to change the default text editor in Linux with only a single command. Here’s how.
For those who prefer something like vim, you can apply changes through the whole system to use it as a default text editor. In order to do that, simply run the following command:
sudo export EDITOR=/usr/bin/vim
This changes the default editor to vim. What if I want to go back to nano? You can do just that by simply running the command once more like we did earlier:
sudo export EDITOR=/bin/nano
Linux distributions such as CentOS use vi by default, which is why users may have a preference for something else.
Change your default text editor with .bashrc
Let’s say Jim wants to use vim and Amy nano. You can do that simply by configuring the file .bashrc for each user:
sudo echo "export EDITOR=/usr/bin/vim" >> /home/Jim/.bashrc && sudo echo "export EDITOR=/bin/nano" >> /home/Amy/.bashrc
.bashrc contains commands to run for when the user logs on. It’s crucial that this particular file may not be tampered in any other way unless you know what you’re doing. Make sure not to use > instead of >>, otherwise you’ll overwrite the entire .bashrc file.
You now know how to change the text editor in Linux at will!