Wikia

Vim Tips Wiki

Provide script-accessible version info in your plugins

Talk0
1,599pages on
this wiki
Revision as of 12:27, April 29, 2008 by JohnBot (Talk | contribs)

Recently created tip

We have not yet decided whether to keep this tip as its own page or merge it somewhere else. If you have a suggestion on the tip content, please edit this page or add your comments below (do not use the discussion page).

Please discuss whether to keep this as a new tip, or whether to merge it into an existing tip, on the new tips discussion page.
created April 25, 2008 · complexity intermediate · author David Fishburn · version 7.0

Most plugins have something like the following at the beginning:

if exists('g:loaded_dbext') || &cp
  finish
endif
let g:loaded_dbext = 1

This prevents the plugin from being sourced more than once. It successfully accomplishes this task, but is essentially useless after that. So I have taken to setting the variable to the version of the plugin, rather than just 1. For example:

if exists('g:loaded_dbext') || &cp
  finish
endif
let g:loaded_dbext = 503

This way, other plugins that utilize my plugin can verify the version, and provide useful error messages or handle things as needed.

References

Comments

Advertisement | Your ad here

Photos

Add a Photo
103photos on this wiki
See all photos >

Recent Wiki Activity

See more >

Around Wikia's network

Random Wiki