vim scripting, if vim version is < 7.3

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

Leave a Comment

File not found.