12

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?

3 Answers 3

16

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
  • 4
    Without 'wildmenu', you get one completion after another via Tab, or still the whole list with Ctrl-D. Suggest mentioning that.
    – derobert
    Feb 5, 2015 at 18:20
  • @derobert Ah, didn't know that. I'm so used to using Tab :-) Feb 5, 2015 at 18:47
  • For settings, :help 'display' is the same as :help display?.
    – wchargin
    Feb 21, 2015 at 0:26
11

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 for subtopics within the documentation for various Vim features usually has an appropriate hyphenated prefix:

:help hl-Menu (cf. :help Menu)
:help syn-on (cf. :help on)
:help help-writing (cf. :help writing)

Similarly, 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)

2
  • 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. Jan 8, 2016 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, 2016 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 and acknowledge that you have read and understand our privacy policy and code of conduct.

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