VI annoyance

Jerry Feldman gaf-mNDKBlG2WHs at public.gmane.org
Wed Aug 11 11:24:30 EDT 2010


On 08/11/2010 09:27 AM, Grant M wrote:
> If you actually type "vim filename" does it behave differently? I seem
> to recall that it did on some platform I worked on. On whatever that
> particular OS was, if you typed "vi filename" it behaved like the
> original "vi", but if you typed "vim filename" it had all of the
> features of a recent vim version. Both commands ran the same vim binary=
,
> but somehow using 'vi' changed the behavior.
>
> Grant M.
>  =20
That is because it uses the name it was called by to set its behavior.
For instances, if you type 'ex filename' you will be in ex mode, but the
executable will still be vim.  The grep and egrep commands work the same
way. /bin/egrep is symlinked to /bin/grep, but the behavior is as if you
typed 'grep -E'. This is a technique that has been used in Unix for the
past 40 years (except Unix generally hard links the commands where Linux
normally symlinks). Remember that the first argument (in C argv[0]) is
always the name of the command that was typed on the command line or
executed through X. The command then sets its behavior based on that.
So, if you type 'view filename' the behavior will be that 'filename' is
edited as read-only.

--=20
Jerry Feldman <gaf-mNDKBlG2WHs at public.gmane.org>
Boston Linux and Unix
PGP key id: 537C5846
PGP Key fingerprint: 3D1B 8377 A3C0 A5F2 ECBB  CA3B 4607 4319 537C 5846







More information about the Discuss mailing list