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.
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.
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 .
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With