When you type vi
in the terminal, the following output is shown
~ VIM - Vi IMproved
~
~ version 7.3.547
~ by Bram Moolenaar et al.
~ Modified by [email protected]
~ Vim is open source and freely distributable
~
~ Help poor children in Uganda!
So according to this, vi
must be launching VIm
.
But when you type vim
it gives
aditya@aditya-desktop:~$ vim
The program 'vim' can be found in the following packages:
* vim
* vim-gnome
* vim-tiny
* vim-athena
* vim-gtk
* vim-nox
Try: sudo apt-get install <selected package>
This shows that vim
is not installed.
Notably man vi
and man vim
launch the same man pages.
So what does the vi
command actually launch?
It is
vim-tiny
: "Vi IMproved - enhanced vi editor - compact version".I did this on 13.10:
As you can see, vim is not installed (empty output), vi is a symlink to /etc/alternatives/vi (see alternatives mechanism), which is a symlink to /usr/bin/vim.tiny, which belongs to package vim-tiny.
If you do
type vi
:You will know where's the binary, now if you do:
It's provided by the alternative
vi
, which can be known by:So, in my case,
vi
is a symbolic link to the alternativevi
which is provided byvim.basic
.You can change which package provided vi if you do
sudo update-alternatives --config vi
It's similar to @ignis answer, but i reduced the steps.It only works, if the file is a symbolic link to another.You can get the original file path easily, if it has thousands of symlinks in it's path.
symlnk-->symlnk-->symlnk-->symlnk-->symlnk-->symlnk-->symlnk-->symlnk-->symlnk-->symlnk-->symlnk-->symlnk-->symlnk-->symlnk-->symlnk-->symlnk-->symlnk-->.................-->original file
So
vi
belongs to the packagevim-tiny
.readlink -f
gives you the canonical path of the file(Original file path).