Vim version details

19 views
Skip to first unread message

Paul Jolly

unread,
May 13, 2019, 11:38:34 AM5/13/19
to vim_use
Hi all,

I've tried searching using various terms, but I can't find anything specific on this question.

Is there a way to get the Vim version number, short of redirecting the output of :version to a variable?

I want the major, minor and patch details to ultimately build a semver version.

I can obviously parse the output of :version (having first redirected it to a variable) but first wanted to check if there was a simpler (less brittle?) way.

Thanks in advance.

tooth pik

unread,
May 13, 2019, 6:06:55 PM5/13/19
to vim...@googlegroups.com
i do it the brittle way
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/3d8f388c-c5a5-4fa1-986f-81a17aaee28b%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Tony Mechelynck

unread,
May 13, 2019, 6:40:00 PM5/13/19
to vim...@googlegroups.com
Major/minor can be got from |v:version|.

If you want to know if a specific patch is compiled-in (let's say
8.0.256) you can test

if (version > 800) || (version == 800 && has('patch256'))

The above intentionally has more parentheses than is strictly
necessary, for the ease of the human reader.

Remember that patch presence/absence is conceptually not a number but
an array of booleans, and it may be quite a large array (for version
8.1 it has as of this writing 1330 bits and climbing): it is possible
for patch n to be compiled-in even if patch (n-1) isn't. AFAIK the
only way to get the full list of which patches are in and which ones
aren't, is to :redir the output of :version somewhere (e.g. to a
register) then to parse (if it exists) the line beginning "Included
patches:" which is near the top of that output. That line can be
absent if you got the initial release of that major/minor version with
no patches.

Best regards,
Tony.
Reply all
Reply to author
Forward
0 new messages