Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

On Debian-based systems the alternatives system handles both the vi and vim executable. So if vim is installed and you execute vi, you also get vim, which I find very nice, because I absolutely hate classic vi.

On Fedora 17 "Beefy Miracle", the alternatives system obviously doesn't handle none of the two. But there is a profile file in /etc/profile.d/vim.sh which adds a shell alias to make vi execute vim. For some reason it does not do that for system users, including root.

But even if I set up an alias for all users manually, when I call sudo vi I'm starting classic vi instead of vim. That's probably because sudo doesn't start a shell or profile files are only executed in interactive shell sessions.

What I'm looking for now is a way to uninstall classic vi completely to make a symlink that even survives system updates. How can I remove classic vi but not vim on Fedora 17? Or is there even a better way?

Update: With yum provides vi I found out that vi is provided by the package vim-minimal. But I can't simply remove it because it automatically removes the package sudo with it. Even if I do remove it, and try to install sudo again afterwards, vim-minimal is then again installed as dependency.

Update: As requested, output of rpm -qf /usr/bin/vi:


And ls -l /usr/bin/vi:

-rwxr-xr-x. 1 root root 782248 13. Feb 2012  /usr/bin/vi
share|improve this question
rm /usr/bin/vi; ln -s /usr/bin/vim /usr/bin/vi. Not an answer because I would personally find a better way (or type vim if I wanted vim). – jordanm Dec 12 '12 at 1:47
@jordanm I meant exactly this when I asked to make a symlink survive an update. How do you ensure the link doesn't get overwritten when vim-minimal package is updated? – aef Dec 12 '12 at 2:51
Is /usr/bin/vi a symlink (to what) or a regular file on Fedora? If a regular file, from what package? – Gilles Dec 12 '12 at 23:10
@Gilles I don't understand your question. – aef Dec 12 '12 at 23:45
Post the output of ls -l /usr/bin/vi and rpm -qf /usr/bin/vi. – Gilles Dec 12 '12 at 23:46
up vote 5 down vote accepted

Your vi is Vim, but invoked as vi, so it enters historical compatibility mode. The recommended action is that if you want to run Vim and not vi, run vim and not vi. However, if you want vi to always run Vim on every account on the system, override it in /usr/local/bin:

cat >/usr/local/bin/vi <<\EOF
exec /usr/bin/vim "$@"
chmod 755 /usr/local/bin/vi
share|improve this answer
That's actually a very nice idea. – aef Dec 13 '12 at 2:35
It even works by simply making a symlink with sudo ln -s /usr/bin/vim /usr/local/bin/vi. But you have to add /usr/local/bin to the left-most side of the Defaults secure_path="…" configuration in visudo, else the symlink won't be found. – aef Dec 17 '12 at 19:33
I think there are some typos in the syntax here. Did you mean cat >/usr/local/bin/vi (not cat >/usr/local/bin)? Did you mean chmod 755 /usr/local/bin/vi (not .../vim)? – D.W. Feb 13 '13 at 2:57

# echo 'alias vi="vim"' >> /etc/bashrc' or # alternatives --install /usr/bin/vi vi /usr/bin/vim 900

share|improve this answer
And doesn't that get erased when the vim-minimal package is updated? – aef Dec 12 '12 at 2:50
create an alias on .bashrc is a good pratice...to me @llua gave a good answer – maniat1k Feb 13 '13 at 11:35

FYI recent fedora (at least since 18) installs that alias gobally in /etc/profile.d once vim-enchanced is installed.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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