93

In Vim's built-in help system, how do I…

  • search for topics that I want help on?
  • follow hyperlinks?
  • browse around for related material?
  • 3
    I never remember the keys for this from one time of using help to the next, but mercifully the help contents are online. vimhelp.appspot.com – chicks Jun 8 '17 at 18:19
99

Vim comes with an exhaustive and fully indexed documentation that contains the answers to most of the questions you may have on using Vim.

But the documentation is huge and may look to the neophyte as an impenetrable maze. Here are a few guidelines to help you find what you need…

  1. The :help command is your gateway to Vim's documentation. Read the first screen now.

    :help
    

    Let's go meta:

    :help help
    
  2. You can complete the arguments with <Tab> and display the list of possible completions with <C-d>.

    :help buf<Tab>
    :help :w<C-d>
    

    By the way, here is an explanation of key notation:

    :help key-notation
    
  3. Most Ex commands can be shortened to a few characters. That's true for :help too:

    :h
    
  4. The :help command and its tab-completion are case-insensitive so the two commands below will get you to the same section:

    :h BufWritePost
    :h bufwritepost
    

    Note that a and A are both legitimate commands so case-insensitivity doesn't apply.

  5. If you only have a generic keyword to search for, use :helpgrep and open the quickfix window:

    :helpgrep quickfix
    :copen
    
  6. Use <C-]> on the highlighted words to jump to the corresponding tag, use <C-t> to come back.

    See :help tags for more.

  7. Scroll around to see if there's a related option or command that better suits your needs. That's a great way to learn new tricks, too.

  8. Use the right syntax to search more efficiently:

    :h :command                        " help for ex-command 'command'
    :h 'option'                        " help for option 'option'
    :h function()                      " help for function 'function'
    :h modifier-key                    " help for 'modifier'-'key' in normal mode
    :h mode_modifier-key               " help for 'modifier'-'key' in 'mode'
    :h mode_modifier-key_modifier-key  " help for 'modifier'-'key' 'modifier'-'key' in 'mode'
    

    Examples:

    :h :sort
    :h 'ai                " only one quote needed
    :h bufnr(             " no need for both parenthesis
    :h v_ctrl-g
    :h i_ctrl-x_ctrl-o
    :h ctrl-w             " no mode required for normal mode
    
  9. Anatomy of a :help section:

    :help ballooneval'
    

    :help ballooneval'

    • The words highlighted in red are the tags associated with that option.
    • The words in green are the long form and the short form of the option name.
    • The first line in white says that it's a boolean option and that it's off by default, see :help options.
    • The second line in white says that the option is global, see :help option-summary.
    • The purple lines are self-explanatory.
    • Then comes the description of the option.
    • The turquoise words are "tags" that let you jump to another part of the documentation. Don't be afraid to follow them.
  10. Use your brain, find logical patterns that will help you for future searches.

    Once you have found the handy :help list-functions, where to look for string-related functions?

    Once you have found :help i_ctrl-x_ctrl-o, how can you find help for <C-x><C-l> in insert mode?

  11. RTFM is not an insult. You will learn a lot more by reading the documentation than by asking short-sighted questions to random strangers so make sure you at least tried to Read The Fantastic Manual before asking.

  • 8
    Good post :-) FYI, your screenshot is rather difficult to read on my screen due to poor contrast (especially the red, and in a lesser degree the purple). – Martin Tournoij Feb 23 '15 at 16:42
  • 8
    I actually updated the help to include a similar list :h help-summary (needs a recent Vim) – Christian Brabandt Mar 11 '16 at 7:05
  • 1
    >4. The :help command and its tab-completion are case-insensitive< ← That's not precisely true: E.g. :h a and :h A are distinguished. – Aaron Thoma Dec 26 '16 at 11:00
  • 2
    :helpgrep can be abbreviated to :helpg for more efficient everyday usage. – Aaron Thoma Dec 27 '16 at 16:41
5

-0.1 make notes about vim in a file. Use it as reference and container.

  1. fast way to find vim help of key | :cmd | 'option' | etc

    • :h gi or :h g; for gi or g; in normal mode
    • :h ^i for Ctrl-i in normal mode
    • :h ^w^w for Ctrl-wCtrl-w in normal mode
    • :h ^wf for Ctrl-wf in normal mode
    • :h i^n for insert mode Ctrl-n
    • :h c^r^r for cmdline mode Ctrl-r Ctrl-r
    • :h :pu for ex-command :put
    • :h 'cb' for option clipboard.
    • :h `> for mark <.
    • :h @: for option repeat last ex command by eval register : (same mechanism as macro).
    • type :h range, at this time you are in cmdline mode, then:

      • type Ctrl-a to complete all candidate that contain range
      • type Ctrl-f to popup a small edit window [Command Line]
      • type "*dd to cut it to system clipboard.
      • type o and Enter to cancel and exit window [Command Line]
      • h :range range() <range> [range] :func-range ... is excerpt
      • similarly, h mode-Ex mode-replace mode-cmdline mode-switching ... is excerpt for mode-.
      • similar word that might be of interest: buf win tab line, etc.
      • summary: this one shows a way to find interesting items given a keyword with help of cmdline-completion.

-0.2 define a buffer-local key-mapping to invoke vim help of word under cursor, when in previously mentioned vim notes file.
(and possibly with post-processing after extract <cword>, in a vimscript function)

  • > define a buffer-local key-mapping to invoke vim help of word under cursor < You can also do setl keywordprg=:help, then K already works – Mass Dec 2 '17 at 13:39
  • Yes, that's one of my settings, K for raw <cword>, the other one I use is <Space>k for <cWORD> with post-precessing. (<Space> is one of my leader key. Also, to be fluent, 'timeoutlen' being set) – qeatzy Dec 2 '17 at 13:50

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.