Ask vim for help
August 10, 2020.
Have you ever struggled to remember how to use a command in vim? Maybe you have used it many times before but you still can’t remember at the moment what usage was like? I do struggle, sometimes. Especially, if there is a new command that I learned recently, I feel the need to check same documentation over and over until it goes without any help. That’s just practicing. On the other hand, vim is a massive editor and one cannot memorize every single command. I need the documentation sooner or later so it must be available.
To get some help, my first reaction usually is get a browser window and google it. Go to some pages that I probably visited before. However, I find that routine quite distracting. That context switch, leaving the development environment and start doing search on the web is like intervening noise to me.
I learned recently there is a better way. Ask vim itself to get help.
substitute command. God knows how many times I googled it. But indeed its pattern might come inconvenient to handle with if it needs to get with some range and with some flags. But that’s OK, I have the vim documentation in place.
help returns the most related page in a window where I can check out all the details.
It is very useful to follow the topics referenced inside the pages. If I want to read more details on a subject, I get the cursor on it, press Ctrl] and vim redirects me there. This is very similar to hyperlinks on the web. I can navigate in vim documentation web with use the usual jump commands - Go back one page Ctrlo and go forward one page Ctrli.