Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I decided to finally learn vi and as I was doing that I realized that vi wasn't behaving as I expected. I learned from another post that this was because, on Ubuntu, vim-tiny is installed by default.

After I learned that I chose to install the full version of vim using the following command:

sudo apt-get install vim

After I did that I became curious about a number of things:

  1. I noticed that vi and vim commands are now associated with the full version of vim and not vim-tiny. How does this happen? (i.e. How does the name look-up work?)
  2. How do I explicitly execute either vim-tiny or full vim?
  3. How does Linux/Ubuntu/apt manage libraries and executables with name clashes? How about different versions?

I'm working on Ubuntu Server 12.04 LTS.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

On Debian-derivatives, it's handled through the alternatives system:

$ ls -l /usr/bin/vim
lrwxrwxrwx 1 root root 21 Jun 11  2010 /usr/bin/vim -> /etc/alternatives/vim
$ ls -l /etc/alternatives/vim
lrwxrwxrwx 1 root root 18 Jun 11  2010 /etc/alternatives/vim -> /usr/bin/vim.gnome

The package post install script (the thing that runs when dpkg says "configuring package X") told the alternative system about a new alternative for vim. The new alternative had a higher priority, so it was picked.

You can run them directly as vim.tiny, vim.full, vim.gnome, etc.

You can override the default using the update-alternatives command.

(Actually, I think vim.tiny works somewhat as a special case, as its not really intended to be used except when space is at a huge premium. At least, it doesn't show as an alternative here.)

share|improve this answer
    
That seems to explain it! However, when I execute vim.tiny it no longer exhibits the strange behavior it did before I installed vim.basic. What's up with that? Perhaps some new libraries came along with vim.basic and changed its behavior? –  AlfaZulu Mar 29 '13 at 18:10
    
@AlfaZulu Yes, you got some new libraries (and vim scripts) with the other vim you installed (and especially with vim-runtime, which came along with it). –  derobert Mar 29 '13 at 18:28

Your Answer

 
discard

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.