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?

Martin Tournoij
  • 62,054
  • 25
  • 192
  • 271
xthrd
  • 5,310
  • 1
  • 15
  • 15

3 Answers3

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.

Martin Tournoij
  • 62,054
  • 25
  • 192
  • 271
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)

Rich
  • 31,891
  • 3
  • 72
  • 139
  • 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 08 '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 08 '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.

xthrd
  • 5,310
  • 1
  • 15
  • 15