This article was originally posted in barbarianmeetscoding.com. 😊
In this 5 minutes of Vim goodness we'll learn about one of the most amazing yet often underused features in Vim and how you can use it to become more effective with Vim. Vim's Help! Here we go!
Vim's help is truly amazing and unique. If whenever you use Vim you run into a problem, or wonder how to do something, or how something works, try typing :h {keyword}
and Vim will do its best to fulfill your wishes and find the help you need. The {keyword}
itself can be a command, a key combination or just something that you want to learn more about:
-
Want to know how the
:global
command works? Then try:h :global
. -
Want to know what the
daw
key combo does? Test:h daw
. -
Want to know about
motions
in Vim? Then try:h motions
. -
Want to know what the
wildmenu
option does in the vimrc? Type:h 'wildmenu'
. -
Want to learn how to quit Vim? Yes. You guessed it. Go
:h quit
-
Want to learn what
CTRL-W
does in insert mode? Try:h i_CTRL-W
Can't exactly find what you want?
Sometimes Vim will have more than one match for the keyword you are searching for. In those cases, Vim will send you to the help page that contains the first match but this might not always be the one you want.
If you can't seem to find exactly what you are looking for, try the following:
Type
:h {keyword}
as usual but don't press ENTER at the end. Instead typeCTRL-D
orTAB
. That will show you all the occurrences of the keyword within Vim's help and may just reveal what you're truly looking for.
Become More Effective Using Vim's Help
Type :h
or :help
and you'll be taken to the help's index which starts with information about how to use the help itself:
How shall I help you, oh master?
This initial help document contains a quickstart guide with a couple of nice tricks that will allow you navigate Vim's help faster:
- Type
<C-]>
to follow a link (you can differentiate links from regular text because links are highlighted) - Use
<C-O>
to go back to where you were before - Use
/{pattern}
to search within a document (that's how you normally search for things in Vim by the way). - The help appears in a normal split window so when you're done with it you can just close it with the
:quit
command just like any other window - Skim
:h help-summary
and:h helphelp
at least once to get a feel for all the things that you can search for in Vim and how to do it.
Remember! You don't need to know these key combinations by heart. Just remember
:help
. Type:help
and you'll be brought to the help about how to use Vim's help where you'll find them again. Help. Help.
Read the Help like a Book
Vim's help is great for precision lightning attacks of curiosity and/or need, like the ones above, but it is also great to peruse and read like a book.
When you type help
, right below the quickstart introductory guide, you have the Vim user and reference manuals. The user manual is essentially a book on how to use Vim, from novice to expert with topics ranging from how to move around in Vim to how to create your own syntax highlighters. The reference manual is an in-depth reference of everything Vim. Both of them are really great.
Get Help with Vim Plugins
One thing that is really cool is that Vim's third party plugins also appear in the help. Just installed a popular plugin and don't quite know how it works? Try :h {nameOfPlugin}
. If you are unsure about the name of the plugin's docs, then take a look at the bottom of the :help
page where you'll find the third party plugins listed:
The type of information that is really useful to look out for is:
- What does it do?
- How do you set it up? Does it work out of the box or does it require some additional setup?
- What are the commands and mappings that it adds to your Vim setup? How can you customize them?
A small warning here: With Vim plugins you will often find that the help you can find inside Vim is far superior to whatever you can find outside (like searching the web). So it is very important to get into the habit of using help, even for plugins, specially for plugins.
Can't Find The Documentation of a Plugin?
You can load the docs from a plugin using the
:helptags ALL
command. But you don't really want to do that manually. Instead, use a plugin manager to load all the docs of your plugins automagically. We will look at how you can do that later in the book.
Awesome! That's it! Hope you found this article useful. Take care!
Top comments (4)
What do use to install plugins?
vim-plug
Vundle
First of all: what's your marvellous color scheme? 🤓
Then, after you'll reply, try to digit: help!
🐰🥚