Vim logo vim online Vim Book Ad

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.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
getVar.vim 1.0 26-Jul-2002 6.0 Salman Halim Initial upload

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to [email protected] after searching the archive. Help Bram help Uganda.
SourceForge Logo