29

I'm running Mac OS X Snow Leopard. How can I check which version of vim I have installed?

Ideally I'd like to know a general solution for checking software versions via the command line.

Gaff
  • 18,569
  • 15
  • 57
  • 68
Stew
  • 1,359
  • 3
  • 12
  • 22

5 Answers5

39

The command:

vim --version

This is pretty standard for all unix executables.

ghoppe
  • 6,460
  • 22
  • 21
  • 1
    It should be mentioned that this command should be entered in the terminal, not inside vim. And you should have vim added to your environment variables if you are on a Windows. – multigoodverse Nov 15 '15 at 17:06
  • 1
    It is worth noting that if all that is wanted is a version number and nothing else (for example, for purposes of deciding whether to take some action based on the version number), then the `--version` output needs to be parsed. I am not aware of a direct way to get Vim's version number (and only the version number) from the command line. Nor am I aware whether line 1 of the output is guaranteed to match a parsing specification. As for a parsing example, in Linux environments you could do: `vim --version | head -1 | sed -e 's|^[^0-9]*||' -e 's| .*||'` – Steve Amerige Jun 16 '21 at 14:34
  • An alternative, more memorable way to filter out the version from the very verbose --version output is `vim --version | head -n1` – mynyml Aug 16 '21 at 14:47
28

or, just if you run vim already and want to know what you are in right now:

:version
akira
  • 61,009
  • 17
  • 135
  • 165
3

In a terminal run vim --version ther version number is in the top line of output.

Martin Hilton
  • 1,486
  • 1
  • 11
  • 11
2

You can also just open a blank VIM document by typing vi or vim in your terminal. The welcome screen will state your version as well as other information.

German
  • 121
  • 2
0

For vim or neovim using regex:

vi --version | grep -oP '(?<=^VIM v)[0-9|.]+'
vi --version | grep -oP '(?<=^NVIM v)[0-9|.]+'

Assumes your grep has perl compatible regex (PCRE).