3

Q1: How can I list all vim help subjects (topics)?
i.e., the {subject} argument for :h[elp] {subject}

Q2: How can I list all vim help files?

My particular use case is that I want to see help for my various vim plugins, and I don't know what the subject is for a given plugin.

I tried :help followed by CTRL-D for commandline completion, but it doesn't show me all the subjects
(e.g., it's not showing me table-mode which is present when I do :help table-mode):

:help
help                               :helptags                          gzip-helpfile
:help                              'helpfile'                         online-help
--help                             'helplang'                         add-local-help
:helpc                             :helpclose                         ale-vim-help-options
:helpf                             'helpheight'                       ale-vim-help-write-good
:helpg                             help-context                       write-local-help
:helpt                             help-summary                       <Help>
t_help                             help-writing                       youcompleteme-help-advice-support
help.txt                           helphelp.txt                       i_<Help>
helphelp                           help-translated                    g:ycm_disable_signature_help
help-tags                          help-xterm-window                  youcompleteme-signature-help
:helpfind                          helpfile_name.txt                  :lhelpgrep
:helpgrep                          netrw-help                         netrw-quickhelp
  • 1
    There are a lot of help tags. A quick :vimgrep "\*.\+\*" $VIMRUNTIME/docs/*.txt to search for tags in the help files returned 7191 results. You might be better off using :h :helpgrep for whatever plugin you're trying to search for. – Jake Grossman Sep 24 at 2:04
  • 3
    Try :helptags ALL and then :help; local plugins help should be displayed somewhere on that page under the heading « local additions » or similar – D. Ben Knoble Sep 24 at 2:07
  • 1
    That's why it is best practice to add a particular help tag for the plugin you are actually using. So I can always do :h pluginname and then search in there. I do that with all my plugins and I think most other plugins I use also do that. – Christian Brabandt Sep 24 at 10:38
4

A1.a: To get a list of all help topics (of which there can be thousands), you can define and call the following function to read all help-tags files into a new buffer:

function! ListHelpSubjects()
    new
    for f in globpath(&runtimepath, '**/doc/tags', 0, 1)
        call append('$', readfile(f))
    endfor
endfunction

which can be put in your .vimrc and called from the command line:

:call ListHelpSubjects()

This gives you a list of all help topics that are known to Vim. Every line contains one help topic, the file where it is defined (which often, but not always hints at the corresponding plugin), and the search pattern that is used for locating the topic in the help file.


A1.b: The following commands are a little bit more complex, but they prefix the names of the help files with their actual directories so that you can put the cursor on them and press Ctrl+W+F to open the help file in another buffer:

function LoadHelpTags(filename)
    let docpath = substitute(a:filename, '\\', '/', 'g')
    let docpath = substitute(docpath, '/tags$', '/', '')

    let tags = readfile(a:filename)

    return map(tags, { idx, val -> substitute(val, '\t', '\t' . docpath, '') })
endfunction

function! ListHelpFileNames()
    new
    for f in globpath(&runtimepath, '**/doc/tags', 0, 1)
        call append('$', LoadHelpFileNames(f))
    endfor
endfunction


As in A1.a, these functions can be put in your .vimrc and called from the command line:
:call ListHelpFileNames()

Actually the last script (A1.b) is not really necessary. You can always press K on the help tags in the list generated by the first example; this will directly open the help file at the correct location.


A2: To get the list of help files only one line needs to be changed (the changed function name is purely cosmetic):

function! LoadHelpFileNames(filename)
    let docpath = substitute(a:filename, '\\', '/', 'g')
    let docpath = substitute(docpath, '/tags$', '/', '')

    let tags = readfile(a:filename)

    return uniq(sort(map(tags, { idx, val -> substitute(val, '.*\t\(.*\)\t.*', docpath . '\1', '') })))
endf

function! ListHelpFileNames()
    new
    for f in globpath(&runtimepath, '**/doc/tags', 0, 1)
        call append('$', LoadHelpFileNames(f))
    endfor
endfunction

The return line now removes everything before and including the first tab and everything after and including the second tab. The remaining file name is again prefixed with the corresponding directory. The list of file names is then sorted and made unique.

| improve this answer | |
  • That gives me exactly what I asked for 👍⭐️ , which then leads me to the question: How can I list all help filenames (a list of distinct filenames)? (i.e., all the files associated with all the topics that the first script above outputs) – Rob Bednark Sep 25 at 0:18
  • @RobBednark See my edited answer. – Jürgen Krämer Sep 25 at 5:39
  • Works beautifully! Thanks @Jürgen! – Rob Bednark Sep 27 at 18:58
  • @Jürgen_Krämer I just noticed that the script you provided in "A2" lists many of the files twice (I get 402 filenames, and 272 unique filenames). Not a biggie, I can just :%!uniq -- but just curious if the script could easily eliminate duplicates? – Rob Bednark Oct 7 at 1:20

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.