Can I create my own parameter variables

I intend to create a set of parameters in vimscript as flags that can then be set at runtime to change the behavior of my script.

How can I create custom parameter variables like other plugins like NERDTree can do this ...

+4
source share
1 answer

A set of Vim options is installed (i.e. the material you control with :set ). But plugins use variables, usually called g:PluginName_OptionName or so, to get something very close to the parameters. With different areas of variables ( g: b: w: you can even achieve something like parameters associated with a buffer or window in Vim: this means that the plugin first checks for the presence of a local variable, and returns to using the global variable, if local does not exist.

Plugins must provide default values ​​for their configuration variables, which can be overridden by the user .vimrc . This is achieved using a test similar to this:

 if ! exists('g:PluginName_ConfigItem') let g:PluginName_ConfigItem = 'default value' endif 

If you plan to publish your plugin, be sure to document the variables and what values ​​they may contain.

+4
source

All Articles