getVar.vim : Convenient retrieval of buffer or global script options.
script karma |
Rating 0/0,
Downloaded by 101 |
created by |
Salman Halim |
|
script type |
utility |
|
description |
This is just two convenience functions that are useful for retrieval of plugin options that can be set globally as well as having buffer-specific over-rides.
Example: I have a global variable called "g:sortOrder" which is set to "a". In the test.java buffer, I create a buffer variable called "b:sortOrder" which is set to "d". Now, GetVar( "sortOrder" ) will return "d" when I'm in test.java and "a" everywhere else. My plugin code doesn't need to actually check for buffer or global variables; I can just call GetVar and be done with it.
GetVar will take an optional second parameter which will be the default value to return if neither a buffer nor a global variable by the specified name is found (the default default :) is -1).
Example: GetVar( "userID", "NONE" ) will take either a userID or the string "NONE" if there isn't one. This can be useful where a script should just use an assumed default if the user hasn't specified an override (global or otherwise).
VarExists simply returns true if either the buffer or the global variable of the specified name exists. |
|
install details |
Pop it into the plugin directory and use in your plugins -- just make sure to add this as a dependence when you submit your plugin to this site. |
|
script versions (upload new version)
Click on the package to download.
|