Vim 101: Getting Help
Vim’s documentation is amazingly detailed and consistent. It’s usually the first place I look for help, before even lazily typing in a query into a search engine. Admittedly, the documentation can be daunting for beginners. Let’s address that now!
Help is Context Sensitive
Pressing escape to ensure Vim’s in Normal mode and then typing :help
and return will display the main Vim help page. Typing :help subject
will search for a given subject. The help file is opened and displayed in a read-only window, usually in a split window at the top of the screen. This window can be closed by entering :q
, just like any other file.
Searching for subjects is context sensitive. If you need help on a Visual mode command, then prepend it with v_
. Similarly, Insert mode commands are prepended with i_
-- for example, :help i_CTRL-P
will display the help for completion.
The options we set using :set option
are found by using single quotes: try entering :help 'write'
and compare it to :help write
. It took me a while to remember this, I seem to distantly remember confusing help lookups for similar commands for Normal mode and options.
To read about the rest of these context-sensitive help searches, type :help help-context
.
Completion
The :help
command supports tab completion if wildmenu
has been set. See help 'wildmenu'
for help on that. The completion algorithm is actually pretty smart, it'll correctly include single quotes for options, and it even recognises all of those i_
keyboard shortcuts.
Navigation
The help pages themselves can be navigated easily by memorising the <C-]>
command. Pressing <C-]>
over a term (highlighted or not) will attempt to jump to a matching help subject. If the mouse is enabled, then double-clicking a word is equivalent.
Pressing <C-T>
(or <C-RightMouse>
) will jump back to the previous location. This is a good way to easily go back through previous pages in case you get lost.
Searching
What happens when you don’t even know the name of a help subject to look up? Well, it’s possible to search through the help using :helpgrep
(or :helpg
). Regular expressions can be used, and to ignore case type :helpg term\c
.
Shortcuts
There are also shortcuts to certain sections. Rather than typing :help normal-index
for help on Normal mode, :viu
can be typed instead. Also, :h
is an alias for :help
.