What do you think? Discuss, post comments, or ask questions at the end of this article [More about me]

It's no secret that I love vim.  It's not for everyone - but taking the time to learn vim has absolutely been wonderful - especially since I also love me some i3wm as well (and use hjkl keys for pretty much everything).

In any case, I often work on various distros and one of the first things I do is set vim to be the default editor.

Unfortunately, there are various ways of doing this depending on which distro you might be using.  Below is a collection of a few approaches:

Setting vim as the default editor

Generic approach

This approach should work in any linux distro and involved setting the bash environment variables $VISUAL and $EDITOR in your .bashrc file:

Open .bashrc (in vim!)

vim ~/.bashrc

and add/append the following lines

export VISUAL=vim
export EDITOR="$VISUAL"

Save and quit, and then close/restart your terminal (or logout and login).

Debian / Ubuntu

Use update-alternatives to set the global system default editor

Run the following from the terminal of your choice

sudo update-alternatives --config editor

Note this sets the default for the whole system... some other (uncultured) users of said system may not like vim so... ah, who cares, just tell them to learn vim!

Use select-editor to set for user

You could also just set the editor of choice at the user level.  Run

select-editor

and select vim from the list of options.

References

  1. https://en.wikipedia.org/wiki/Vim_(text_editor)
  2. https://unix.stackexchange.com/questions/73484/how-can-i-set-vi-as-my-default-editor-in-unix