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
  • 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

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
  • That's actually a very nice idea. – aef Dec 13 '12 at 2:35
  • 2
    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
  • To pick it up with root's default PATH, create the symlink at /usr/local/sbin/vi. – hackel Sep 25 at 16:49

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

  • 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.

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.