I wanted to understand the difference between the executables vi and vim. which has led me to /usr/bin/, and there I've found the following symlinks:

/usr/bin/vi -> /etc/alternatives/vi
/usr/bin/vim -> /etc/alternatives/vim

Going to /etc/alternatives/, I saw that these names link back to /usr/bin/:

/etc/alternatives/vi -> /usr/bin/vim.gnome
/etc/alternatives/vim -> /usr/bin/vim.gnome

After wondering a bit why is it so, I came to the conclusion that both are pointing to the same executable, hence they are completely the same.

However, something cought my eye that moment; this link:

/etc/alternatives/view -> /usr/bin/vim.gnome

accompanied with this link:

/usr/bin/view -> /etc/alternatives/view

Now, that's weird, since I know that when I run view it's not the same as when I run vim; it opens a read-only mode of the file given as an argument. Does vim.gnome binary knows what was linking to it when executed, somehow?

(by the way, same issue is with vimdiff)

Do you have an explanation for that?

1 Answer 1


This is explained in man vim:

Vim behaves differently, depending on the name of the command (the executable may still be the same file).

The "normal" way, everything is default.

Start in Ex mode. Go to Normal mode with the ":vi" command. Can also be done with the "-e" argument.

Start in read-only mode. You will be protected from writing the files. Can also be done with the "-R" argument.

gvim gview:
The GUI version. Starts a new window. Can also be done with the "-g" argument.

evim eview:
The GUI version in easy mode. Starts a new window. Can also be done with the "-y" argument.

rvim rview rgvim rgview
Like the above, but with restrictions. It will not be possi‐ ble to start shell commands, or suspend Vim. Can also be done with the "-Z" argument.

In other words, vim will detect the name it was invoked as and act accordingly. Another example of a program that behaves differently depending on which name it was run as is bash which acts as a minimal POSIX shell if called as sh (see INVOCATION in man bash).

  • This is great; but how vim knows the name of the command?
    – Bach
    Apr 9, 2014 at 15:45
  • 2
    @Bach the name that a program is called by is available to that program. The details depend on the language used but, for example, in bash and perl you have $0. In C, which is what vim is written in, the name the executable was called by is stored in argv[0] and it is trivial to set up a few tests that make the program behave differently according to the value of argv[0].
    – terdon
    Apr 9, 2014 at 15:53

You must log in to answer this question.

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