1

When i do a ls -l /usr/bin/vimdifff it shows following

/usr/bin/vimdiff -> vim

Does this mean vimdiff and vim are the same?

I know that we can use vim for diff by giving -d. But how does linking like this makes the vim work as a difftool.

3

The vim binary is able to answer by many names and it will tweak its behavior based on which name it is called.

This is a somewhat common practice in Unix, where a program will support checking the name by which it's invoked and will behave differently depending on that name.

At installation time, a single binary will be copied, but symbolic links or hardlinks will be created to make it available under all possible names.

In case of vim, it actually supports being called under quite a variety of names. You can see a comprehensive list under :help vim-arguments:

The startup mode can be changed by using another name instead of vim, which is equal to giving options:

  • ex (vim -e): Start in Ex mode.
  • exim (vim -E): Start in improved Ex mode.
  • view (vim -R): Start in read-only mode.
  • gvim (vim -g): Start the GUI.
  • gex (vim -eg): Start the GUI in Ex mode.
  • gview (vim -Rg): Start the GUI in read-only mode.
  • rvim (vim -Z): Like vim, but in restricted mode.
  • rview (vim -RZ): Like view, but in restricted mode.
  • rgvim (vim -gZ): Like gvim, but in restricted mode.
  • rgview (vim -RgZ): Like gview, but in restricted mode.
  • evim (vim -y): Easy Vim: set 'insertmode'.
  • eview (vim -yR): Like evim in read-only mode.
  • vimdiff (vim -d): Start in diff mode.
  • gvimdiff (vim -gd): Start in diff mode.
|improve this answer|||||
  • 1
    Worth mentioning that this is done via the 0th parameter (e.g., argv[0] in C or $0 in sh) – D. Ben Knoble Jan 15 at 13:46

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.