Today I Learned

hashrocket A Hashrocket project

Get Vim Help for Current Word

Some Vim users may be familiar with K, which runs a program to lookup the keyword under the cursor. If not, try typing K over puts and watch the magic happen.

I wanted the same functionality for Vimscript keywords, so I added this mapping to my ~/.vimrc:

nnoremap <F1> :help <C-r><C-w><CR>

This maps F1 (or your key of choice) to, basically, run 'help' followed by whatever word is under the cursor, in normal mode. After sourcing your configuration file, you can try it on nnoremap— you should see the corresponding help page from map.txt.

See More #vim TILs
Every developer at Hashrocket is a Vim expert. Check out our development environment, Dotmatrix, and if you are in Chicago, come to the Vim Chicago Meetup hosted at our Chicago office.