--- tag: vim --- How to Use Vim's Built-in Help ============================== Vim has a comprehensive built-in manual. Unfortunately you need some help to know how to use the help. This post is a quick reference and tutorial for Vim's :help files.
#### See also * :help opens Vim's "main help file" ([`help.txt`](https://vimhelp.org/)). There's a short tutorial on how to use the help files at the top. * :help helphelp opens [`helphelp.txt`](https://vimhelp.org/helphelp.txt.html), which is the full documentation for the `:help` commands and how to use the help files. * The Getting Started pages of the docs also have a [Finding Help](https://vimhelp.org/usr_02.txt.html#02.8) section (:help 02.8 from within Vim) * You can browse and search all of the help pages online at (you _don't_ want to use the copy at , it's hopelessly out of date) * The [quickref](https://vimhelp.org/quickref.txt.html) (:help quickref) and [index](https://vimhelp.org/index.txt.html) (:help index) are two handy help pages. vimhelp.org also has the [VIM FAQ](https://vimhelp.org/vim_faq.txt.html) (which I don't think is available from inside Vim).
## Opening the help window :help (or just :h) opens the "main help file" (the front page of the help manual, `help.txt`) in a new window. F1 does the same thing. The Help key on your keyboard might also work if it has one. Use :vert help to open it in a vertical split instead of a horizontal one, or :tab help to open it in a new tab. I don't think it's possible to open a help file in or in-place-of the current non-help window. If there's already a help window open :help will use that window instead of opening a new window (even if the cursor is currently in a different window). :help {subject} (or just :h {subject}) opens the help tag `{subject}`. `{subject}` can be lots of different types of thing: * Topics, e.g. [:help deleting](https://vimhelp.org/change.txt.html#deleting) or [:help options](https://vimhelp.org/options.txt.html) * Normal-mode commands: [:help x](https://vimhelp.org/change.txt.html#x) or [:help cc](https://vimhelp.org/change.txt.html#cc). Use `ctrl-` for commands that're prefixed with Ctrl, e.g. [:help ctrl-a](https://vimhelp.org/change.txt.html#CTRL-A). Use `_` for multi-key commands, e.g. [:help ctrl-w_w](https://vimhelp.org/windows.txt.html#CTRL-W_W). `^` also works insead of `ctrl`, e.g. :help ^p is the same as :help ctrl-p. Names of special keys need to be wrapped in angle brackets, e.g. [:help ctrl-w_<Up>](https://vimhelp.org/windows.txt.html#CTRL-W_%3CUp%3E). See [:help keycodes](https://vimhelp.org/intro.txt.html#keycodes) for the names of all the special keys. * Insert-mode commands have an `i_` prefix, e.g. [:help i_ctrl-r](https://vimhelp.org/insert.txt.html#i_CTRL-R) * Visual-mode commands have a `v_` prefix, e.g. [:help v_o](https://vimhelp.org/visual.txt.html#v_o) * Ex commands start with `:`, e.g. [:help :substitute](https://vimhelp.org/change.txt.html#:substitute) * Keyboard commands that you can use when in Vim's command-line mode start with `c_`, for example [:help c_ctrl-r](https://vimhelp.org/cmdline.txt.html#c_CTRL-R). Special characters for use in Ex commands also use `c_`, for example: [:help c_%](https://vimhelp.org/cmdline.txt.html#c_%). * Vim command-line arguments start with `-`, e.g. [:help -t](https://vimhelp.org/starting.txt.html#-t) * The names of settings have to be wrapped in single quotes, e.g. [:help 'number'](https://vimhelp.org/options.txt.html#'number') * Error messages have their own help tags, e.g. [:help E37](https://vimhelp.org/message.txt.html#E37) * And more! See [:help help-summary](https://vimhelp.org/usr_02.txt.html#help-summary) for the complete list of help tag types ## Closing the help window [:q](https://vimhelp.org/editing.txt.html#:q) or [ZZ](https://vimhelp.org/editing.txt.html#ZZ) will close a help window like any other window if the cursor is in the help window. [:helpclose](https://vimhelp.org/helphelp.txt.html#:helpclose) or [:helpc](https://vimhelp.org/helphelp.txt.html#:helpc) will close the help window even if the cursor isn't in it. ## Navigating in the help window Vim's help files are peppered with highlighted "tags" that're links to other locations in the help files. The tags work as links for jumping back and forth: * [Ctrl-]](https://vimhelp.org/tagsrch.txt.html#CTRL-]) goes to the help tag under the cursor. [Ctrl-]](https://vimhelp.org/tagsrch.txt.html#CTRL-]) is Vim's general "jump to definition" command, it can be used to jump to the definitions of things in code too. If you have mouse mode enabled (:set mouse=a) then double-clicking on a tag also follows it. * [Ctrl-t](https://vimhelp.org/tagsrch.txt.html#CTRL-T) or [Ctrl-o](https://vimhelp.org/motion.txt.html#CTRL-O) go back to the previous location (repeat to keep going back to prior locations). These are Vim's general commands for going back to older positions in the [tag stack](https://vimhelp.org/tagsrch.txt.html#tag-stack) (Ctrl-t) or [jump list](https://vimhelp.org/motion.txt.html#jump-motions) (Ctrl-o). :tag and [Ctrl-i](https://vimhelp.org/motion.txt.html#CTRL-I) go forward again. ## Searching for help topics :help {subject} (or just :h {subject}) opens the help tag `{subject}`. `{subject}` can include wildcards like `*`, `?` or `[a-z]`. If there are multiple help tags matching the given subject then when you press Enter Vim opens the "best" match. See [:help {subject}](https://vimhelp.org/helphelp.txt.html#{subject}) (literally) for details of the algorithm Vim uses to decide which match is best. You can use [Ctrl + d](https://vimhelp.org/cmdline.txt.html#c_CTRL-D) or [Tab](https://vimhelp.org/cmdline.txt.html#c_) to search for tag names. For example type :help buffer and then instead of Enter press Ctrl + d or Tab to see a list of all help tags matching "buffer". This doesn't just list all tags that start with "buffer", it lists all tags that match "buffer" according to the matching algorithm Vim uses. It includes all tags that have "buffer" anywhere in the tag name. ## Searching the full text of help files with `:helpgrep` [:helpgrep {pattern}](https://vimhelp.org/helphelp.txt.html#:helpgrep) or [:helpg {pattern}](https://vimhelp.org/helphelp.txt.html#:helpg) does a full-text search of all help files for `pattern` and opens the first match. It populates the quickfix list with all the matches so you can use quickfix commands like [:cn](https://vimhelp.org/quickfix.txt.html#:cn) to go to the next match, [:cp](https://vimhelp.org/quickfix.txt.html#:cp) to go to the previous match, [:copen](https://vimhelp.org/quickfix.txt.html#:copen) to open the quickfix window with the list of all matches. See [:help quickfix](https://vimhelp.org/quickfix.txt.html) for how to use the quickfix window. Patterns are case-sensitive, regardless of the `ignorecase` setting, unless you append `\c` to the end of the pattern. [:lhelpgrep](https://vimhelp.org/helphelp.txt.html#:lhelpgrep) (or just [:lh](https://vimhelp.org/helphelp.txt.html#:lh)) does the same but uses the help window's [location list](https://vimhelp.org/quickfix.txt.html#location-list), so it doesn't mess up your quickfix list. You can also use Google to search the full text of vimhelp.org: [google.com/search?q=quickfix site:vimhelp.org](https://www.google.com/search?q=quickfix+site%3Avimhelp.org). Or Duck Duck Go: [duckduckgo.com/?q=quickfix site:vimhelp.org](https://duckduckgo.com/?q=quickfix+site%3Avimhelp.org).