How do I replace vi by vim so that when I type vi in terminal vim is opened?


'vi' in Ubuntu already starts 'vim', although by default it starts 'vim-tiny' (which comes closest to the original 'vi' in its (lack of) features). You can see this with:

sudo update-alternatives --display vi

If you want it to use another version of vim, then make sure it's installed and run:

sudo update-alternatives --config vi
  • Can I use update-alternatives for other applications, what does update-alternatives do, does it installs extra features ?
    – Searock
    Oct 12 '10 at 17:52
  • Yes you can. It updates alternatives. No, it doesn't. If you want to know more use man update-alternatives or start a new question.
    – Martin
    Oct 12 '10 at 18:36
  • This should be marked as the correct answer, instead of the workaround that was accepted!
    – OmarOthman
    Dec 24 '15 at 14:29

You can add

alias vi=vim

to ~/.bashrc . This will start vim whenever you type vi.

Note that in Ubuntu 10.10 (and I think also 10.04) vi is already mapped to vim.

  • Sorry for another silly question, but where is .bashrc located ? I am quite new to Ubuntu.
    – Searock
    Oct 12 '10 at 17:46
  • In your home directory. Just type vim ~/.bashrc
    – Peter Smit
    Oct 12 '10 at 17:47
  • 3
    Actually, 'vi' has pointed to some variation of 'vim' since almost forever in Ubuntu (see my answer about alternatives to know how to change which variation).
    – JanC
    Oct 13 '10 at 6:31

In addition to what Peter Smit has suggested. You can do the following as well to make that change system wide rather than just your account.

add alias vi='vim' to /etc/bash.bashrc

or create a symlink to vim

sudo ln -s /usr/bin/vim /usr/bin/vi

However on my system both /usr/bin/vim and /usr/bin/vi are symlinks to /etc/alternatives/vim

  • 2
    The symlink is a bad suggestion: use update-alternatives to manage this in Ubuntu.
    – Roger Pate
    Oct 13 '10 at 17:45
  • 1
    yes I agree do it the correct way. I didn't know that vim was using the alternatives system. Oct 13 '10 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.