10

Occasionally, when I'm searching the help system for a particular topic, it will be shadowed by a different topic.

For example, if I do :h display I get help for something involving "GUI Resources", when I wanted help for the "display" setting (as in set display=lastline).

How can I find these "shadowed" topics, or list the most relevant matching topics?

13

Setting names are always surrounded by quotes, so use:

:help 'display'

to get the page you want.

You get some useful completions when pressing Ctrl+D, ie:

:help display<^D>

Will give you:

-display  :display  'display'  :syn-display  strdisplaywidth()

As completions :-)

Bonus tip:
If you use :set wildmenu, this will also work with Tab, and you will have some additional completion features.

  • 3
    Without 'wildmenu', you get one completion after another via Tab, or still the whole list with Ctrl-D. Suggest mentioning that. – derobert Feb 5 '15 at 18:20
  • @derobert Ah, didn't know that. I'm so used to using Tab :-) – Martin Tournoij Feb 5 '15 at 18:47
  • For settings, :help 'display' is the same as :help display?. – wchargin Feb 21 '15 at 0:26
9

Help for Ex commands is always listed with the colon included:

:help :display

Help for settings is always listed with surrounding quotes, as Carpetsmoker already described:

:help 'display'

Specific help files are listed by their file name:

:help undo.txt (cf. :help undo)

Help for built-in functions is listed with trailing parentheses:

:help split() (cf. :help split)

Documentation for Vim's command arguments (i.e. those passed when invoking Vim from the shell) is listed with preceding hyphens:

:help -r (cf. :help r)

Help topics within plugins generally use the plugin's name as a prefix:

:help surround-mappings

Finally, something I didn't realise until I'd been using Vim for a while* is that the help includes topics for the default mappings in all modes.

For example, Ctrl-v does something very different in Normal mode to what it does in Insert mode.

To get to the different topics, use the i_, c_, and v_ prefixes for Insert, Command, and Visual mode mappings, respectively, or no prefix for the Normal mode mapping:

:help ctrl-v

:help i_ctrl-v

:help c_ctrl-v

:help v_ctrl-v

* ...despite the fact that it's virtually the first thing you'll read if you type a plain :help with no arguments! See "Get specific help" a few paragraphs down. (:help help-context)

  • Most, though not all (specifically functions and plugins), of these are listed in :help help-context: Maybe that is worth mentioning in the answer as well. – Sakari Cajanus Jan 8 '16 at 10:57
  • @SakariCajanus Yes! help-context is actually almost the first thing on the front page of Vim's :help. I've added a footnote mentioning this to the answer. – Rich Jan 8 '16 at 12:01
4

@Carpetsmoker's answer definitely satisfies the "most relevant" criteria, because the completions will almost always contain what you're looking for. However, there's also the :helpgrep command, which works just like the :grep command but searches the text of all the help files.

You can browse through the results with :cnext or see all the results with :cwindow.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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