11

I recently found out that YouCompleteMe has an g:ycm_autoclose_preview_window_after_insertion option that automatically hides the documentation preview window after exiting insert mode, and I also recently started out using vim, so this was the first time I set an option.

So I wondered if other plugins I crammed in my vim environment have options available, without searching for them manually.

Are they registered globally when vim starts, in order for a command that lists them to be available, or this can't be done?

1
  • You can't. Variables for plugins need to be documented. There is no way to know, what variables are used without reading the code. Commented Dec 30, 2016 at 12:42

2 Answers 2

7

Vim doesn't provide any way to know all possible plugin options.

As a plugin writer I can tell you this is quite complex as there are many different ways to proceed. For instance either we consider that if the end-user hasn't provided a value for an option in its .vimrc then we force this option to exist and to be equal to a default value, or we can say: "either take the value set by the end-user, or use an hard-coded default value".

With that first approach, the end-user can see the list of available options with a c_CTRL-D, or c_TAB, etc.

More and more plugins choose to organize all their options into dictionaries. i.e., instead of having g:plugin_foo_option and g:plugin_bar_option, we have g:plugin.foo_option and g:plugin.bar_option. This avoids polluting the list g: of global options, but we lose command-line autocompletion (I may eventually open an issue of the subject, on vim github).

So far I have only talked about global options. Most plugins don't try to support more specific options even if they should have done it. For instance, I regret that neither YouCompleteMe nor alternate, nor many other plugins, use project specific options instead of global options. Indeed, depending on the project I'm working on I want to set their respective options to different values. Unfortunately, this is not a work-flow they have considered. In my plugins, many options can be specialized on project basis, or on buffer basis. Lately I've come up with an experiment on the subject. But even with the usual and simple g:plugin_option + b:plugin_option pair, it's next to impossible to know all available options.

Sometimes I try to offer commands that help setting options as I've done with build-tools-wrappers, or even to display some options in the menu (when using gvim), but it's really far from being perfect.

I'm afraid that the documentation is the best thing available. You can even try a :h pluginname^D. It's probably the best approach available.

1
  • Great explanation of the options behind the scenes. And the :h pluginname is actually very great! So I don't have to go away from vim multiple times to read different plugins' documentation. Commented Jan 4, 2017 at 6:25
2

Vim doesn't have a referential of the available options. the best you can do is to see what have been initialized.

For Vim's built-in options there is the command :set. From :h :set:

:se[t] Show all options that differ from their default value.

You will not see all the available options, only the ones you modified.

You can also use :let to list the value of all the declared variables and :let g: for a list of the global variables. (See :h E121 for a list of the variable you can show).

Note that these lists are not always easy to read/parse. For the plugins, your best option is to read the documentation and find the option you need.

You may also be interested by this wikia tip how to display vim environment

1
  • Accepted the other answer as it's more verbose, though this has interesting commands related to my question that might help. Commented Jan 4, 2017 at 6:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.