Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim scripting, if vim version is < 7.3

I was looking around for it for quite a while.

I want to add a line to a vim plugin file that would disable it if running on unsupported version of vim.

I remember from somewhere that it goes something like that:

if version > 730     "plugin code goes here endif 

but that fail.

like image 793
GoTTimw Avatar asked Aug 02 '12 09:08

GoTTimw


People also ask

How do I find my vim version number?

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.

Does vim have version control?

Yes, you can add undo branches functionality that makes it more like a version control system. In vim 7.3 you can have persistent undo, as described here, you only need to add the following lines to your . vimrc .


1 Answers

The versioning scheme is different; Vim 7.3 is 703, not 730.

Also, for clarity, I would recommend using v:version (this is a special Vim variable).

Often, it is also better to check for the availability of features ( e.g. exists('+relativenumber')) than testing for the Vim version that introduced the feature, because Vim can be custom-compiled with different features.

Finally, plugins typically do the guard the other way around:

if v:version < 703     finish endif " Plugin goes here. 

And it's a good practice to combine this with an inclusion guard. This allows individual users to disable a (system-wide) installed plugin:

" Avoid installing twice or when in unsupported Vim version. if exists('g:loaded_pluginname') || (v:version < 700)     finish endif let g:loaded_pluginname = 1 
like image 83
Ingo Karkat Avatar answered Sep 21 '22 22:09

Ingo Karkat