I have vim 7.4 installed, but I'm not sure what patch level it was at when I installed it. How do I check?

vim --version


VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 15 2014 16:18:44)

But it doesn't give the patch level or a minor version number.


You seem to simply have an unpatched version of vim, otherwise the :version command or the --version parameter would list the patches on the second line. For example on my machine it says:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Sep 10 2014 09:36:33)
Included patches: 1-207, 209-355, 357-430

This is "patchlevel" 430, but it skips patches 208 & 356.

Vim doesn't have a "minor version number" beyond major.minor; although I believe that some distributions may use the "patchlevel" as such.

As shown above, not all patches may be included, so if you want to use this value you can't just check if a number is higher than a certain version.

Usually, the best way is to use has("patch-7.4-399"); this will return true if:

  • We're running Vim 7.4 with patch 399 included.
  • We're running Vim 7.5 or later.

You can also use the form of has('patch399'), which is typically used like:

if v:version == 704 && has('patch399')

But be aware; this will be false for Vim 7.5; use this only in very specific cases.

See :help feature-list for some more information.

I can't find a way to list all the included patches, other than redirecting :version and parsing that ... I'm also not sure how this would be useful anyway, as has() should be enough :-)

  • 2
    Is it has("patch-7.4-399") or has("patch-7.4.399")? (the latter was suggested to me by some code-completion, and also seems to be what's actually described at the link you provided)
    – akavel
    Mar 24 '15 at 9:49
  • 2
    @akavel They both work. You could even use patch-7-4-399 ;-) Mar 24 '15 at 9:50
  • ahh, awsum, then :)
    – akavel
    Mar 24 '15 at 12:12
  • 4
    The patch-7.4.399 format is only available after 7.4.237. See :h has-patch.
    – blueyed
    Jun 29 '16 at 19:32
  • 2
    ↑ @blueyed is referring to the whole has('patch-7.4-399') feature of checking both the major.minor and the patch versions in one swoop (w/o resorting to v:version): independent of whether using - dashes or . dots. Oct 17 '17 at 4:33

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .