Change the default editor in Linux

The Mythical Engineer


change-the-default-editor-in-linux

You can change the default command-line text editor on a ubuntu server used by various programs, such as crontab. For example, many servers are configured to use nano as the default text editor. However, if you like vim more than nano, you may want to use it as the default editor instead.

There are multiple ways to do it.


Method #1 : Use the select-editor command

select-editor command lists the available editors on a system and interactively prompts the user to select one.

$ select-editor

Select an editor.  To change later, run 'select-editor'.
  1. /bin/nano        <---- easiest
  2. /usr/bin/vim.basic
  3. /usr/bin/vim.tiny
  4. /bin/ed

Choose 1-4 [1]:

Type 3 and press Enter. Now your default editor is vim.


Method #2: Set default editor in .bashrc file.

Find the path to your preferred editor.

$ which vim
/usr/bin/vim

Add this line to your .bashrc

export EDITOR="/usr/bin/vim"

and run

source ~/.bashrc

Your default editor will be set to vim. This method should work for most of the linux distributions available.


#development  #linux  #ubuntu  #server 

Suggested Reading

  • * How to install Cursor AI IDE on Fedora Asahi Linux Arm64

    * Revert a commited secret from remote repository

    * From Chaos to Control: Using Direnv to Manage Multiple GitHub Accounts

    * How Postgres Triggers Can Simplify Your Backend Development

    * Running Rust Kernel in Deepnote

  • Share this:


    Comments


    Leave a Reply

    Your email address will not be published. Required fields are marked *