Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Guys, anyone know how to change linux console editor from vi into vim everytime we execute vi? I'm using Ubuntu and Fedora Core

share|improve this question

migrated from Aug 21 '09 at 10:42

This question came from our site for professional and enthusiast programmers.

Just curious: What Linux dist. is that? I can't recall ever seeing a old school Vi as default. – Brian Rasmussen Aug 21 '09 at 10:14
In fact, it is extremely unlikely to be vi, as that wouldn't be FOSS code. – nb2580 Aug 21 '09 at 10:19
From memory is that some distro (I think it was RHEL), they configured the command vi to classic mode in VIM. – Seh Hui Leong Aug 21 '09 at 10:45
Why execute vi if you prefer vim? export EDITOR=vim? – Tadeusz A. Kadłubowski Aug 21 '09 at 11:29
Arch also have a "vi" clone by default, instead of vim. – Hugo Apr 4 '12 at 17:43
up vote 27 down vote accepted

First, make sure you have the proper Vim packages installed. The default on many systems is to install a minimal Vim package that is closer to Vi in functionality.

On Red Hat based systems (RHEL, CentOS, Fedora), you need the vim-enhanced package, for example from a CentOS system I have installed:


'common' contains common libraries used by all the Vim packages. 'minimal' is the plain vi editor executables as installed by default.

On Debian based systems (like Ubuntu), you need 'vim'. For example:

ii  vim                  2:7.2.079-1ubuntu5  Vi IMproved - enhanced vi editor
ii  vim-common           2:7.2.079-1ubuntu5  Vi IMproved - Common files
ii  vim-runtime          2:7.2.079-1ubuntu5  Vi IMproved - Runtime files
ii  vim-tiny             2:7.2.079-1ubuntu5  Vi IMproved - enhanced vi editor - compact version

These should be installed by default. On Debian/Ubuntu, you can update the default system editor for all users:

sudo update-alternatives --config vi

Select the version you want from the selection menu. Post installation scripts for the vim package should have already updated this, though. Use --config editor to change the default editor for all users on the system (Ubuntu 9.04 original default is nano, for example).

Finally, on a per user basis for any distribution, set up an alias in the user profile. For example if the shell is bash, edit ~username/.bashrc:

alias vi="vim"

Also, you may check the system vimrc (/etc/vimrc, usually) to see if compatibility mode is turned on.

set cp
set compatibility

Will tell Vim to behave more like old-school Vi, no matter how you've handled using Vim per above. Change to 'nocp' or 'nocompatibility' to make Vim more useful.

share|improve this answer
thanks, this is what I really need – Funky81 Aug 22 '09 at 0:15
On recent versions of ubuntu, only vim-tiny is installed by default. Install vim to get the full version. – Hamish Downer Sep 9 '09 at 20:08

In your .bashrc:

alias vi=vim
share|improve this answer
This will not affect anything that is not using bash, e.g. when you press "v" inside of less(1) it will still run the "real" vi. – Kevin Panko Aug 21 '09 at 15:11
The environment variables EDITOR and VISUAL will take precedence when you hit v over the default vi command. So, in your .bashrc export EDITOR or VISUAL with vim as its value; e.g., export EDITOR=vim and export VISUAL=vim in your .bashrc – Nitrodist May 31 '11 at 19:38

If it is a Debian or Ubuntu system, and you want to make this change system wide, you should use update-alternatives (specify with the --config editor options, and you should be golden)

share|improve this answer

If you need the changes only for your id, and within a terminal session: alias vi to vim as suggested by AI.

If you want a system-wide change on your machine, soft-link to vim in /usr/local/bin:

sudo ln -s `which vim` /usr/local/bin/vi

Note: Programs can ignore any aliases on vi by running command vi or \vi instead of just vi.

share|improve this answer

Some dists use vim:s old school mode where it behaves like vi.

check if your .vimrc contains

set nocompatible

I have been fooled by this a couple of times....

share|improve this answer

On Debian systems, when you execute the default vim-tiny as 'vi', a different RC file is used - /etc/vim/vimrc.tiny.

To make 'vi' act more like 'vim', edit /etc/vim/vimrc.tiny and change the line:

set compatible

to read:

set nocompatible
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .