Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Making .vimrc compatible with /bin/vi too?

28 views
Skip to first unread message

Tony Mountifield

unread,
May 11, 2012, 6:10:07 PM5/11/12
to
There are a couple of things in my .vimrc that vim complains about when
the minimal version in /bin/vi is invoked.

I would like to make that section of my .vimrc conditional, only to be
executed when the full version of vim in /usr/bin/vim is invoked.

What is the correct condition to use to detect which of the two versions
of vim is running? I have searched the help and online, but can't see the
wood for the trees!

Thanks for any advice...

Tony
--
Tony Mountifield
Work: to...@softins.co.uk - http://www.softins.co.uk
Play: to...@mountifield.org - http://tony.mountifield.org

Eli the Bearded

unread,
May 11, 2012, 7:25:11 PM5/11/12
to
In comp.editors, Tony Mountifield <to...@mountifield.org> wrote:
> There are a couple of things in my .vimrc that vim complains about when
> the minimal version in /bin/vi is invoked.

I only have one version of vim installed, so I don't have that
problem.

> I would like to make that section of my .vimrc conditional, only to be
> executed when the full version of vim in /usr/bin/vim is invoked.
>
> What is the correct condition to use to detect which of the two versions
> of vim is running? I have searched the help and online, but can't see the
> wood for the trees!

:if has("FEATURENAME")
:"some commands
:endif

Pick a feature you are relying upon for your settings. See :version
for features (and don't include the + or - that preceeds them there).

Elijah
------
uses ed when he wants a minimal editor

Tony Mountifield

unread,
May 12, 2012, 5:23:24 AM5/12/12
to
In article <eli$12051...@qz.little-neck.ny.us>,
Great, thanks! I had found the has() function, but not :version to list
all the things I could test for.

Cheers

Tony Mechelynck

unread,
Jun 19, 2012, 9:05:51 PM6/19/12
to
On 12/05/12 00:10, Tony Mountifield wrote:
> There are a couple of things in my .vimrc that vim complains about when
> the minimal version in /bin/vi is invoked.
>
> I would like to make that section of my .vimrc conditional, only to be
> executed when the full version of vim in /usr/bin/vim is invoked.
>
> What is the correct condition to use to detect which of the two versions
> of vim is running? I have searched the help and online, but can't see the
> wood for the trees!
>
> Thanks for any advice...
>
> Tony
>

If your /bin/vi is actually, as is often the case, compiled from the Vim
sources, but with most features turned off including expression
evaluation, you can wrap your vimrc between "if 1" at the start and
"endif" at the end. The versions of Vim compiled with no expression
evaluation recognise the :if construct and treat it (both the "true and
"false" paths) as a nestable comment.

See :help no-eval-feature


To know what your /bin/vi actually is, type

/bin/vi --version

at the shell command-line, or try

:version

in a running vi.


Best regards,
Tony.
--
As Will Rogers would have said, "There is no such things as a free
variable."

0 new messages