This guide will show you how to change default text editor in Linux

Many users on Linux preferred to use their favorite text editors to edit files on Linux, but some programs on Linux use default text editor, such as “crontab -e”, many user accounts are configured to use emac as their default text editor, however, if your favorite text editor is vim, you may want to use it as your default text editor instead of emac. To change default text editor in Linux follow these simple steps below:

`

1. Log in with your account using SSH.

2. open and edit .bash.rc file.

vim .bashrc

3. Add the following contents at the bottom of .bashrc file and replace the values according to your requirements

export EDITOR='program'
export VISUAL='program'

My favorite text editor is vim so my .bashrc file will looks like this after adding vim as my default text editor

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi
export EDITOR='/usr/bin/vim'
export VISUAL='/usr/bin/vim'

4. Save the changes and exit the .bashrc file.

5. Now log out from your account and log in back to change the default text editor changes effect or type the following command if you want the changes takes effect without log out:

source .bashrc

Similar Posts