1

When I write an answer on this site, I often want to link to a part of Vim's :help pages; http://vimhelp.appspot.com/ has an online version of that.

However, I'm too lazy to manually lookup the page online, and add links for that.

What I want to do is somehow make Vim generate an valid URL to part of the helpfile I'm currently viewing. For example:

:echo WebHelp()
[`:help split`](http://vimhelp.appspot.com/windows.txt.html#%3Asplit)

The links on vimhelp.appspot seem to correspond to the same file & tags as Vim uses.

I know I can get the current file with :echo expand('%') (windows.txt in the above example), and I know how too url-encode string, but I'm not sure how to get the nearest tag the cursor is at? (:split)?

1 Answer 1

2

Tags in help files are enclosed within * characters. So to find the closest one above the current position I would search with

 ?\*[^*]\+\*

As there can be a number of such tags after the main/header tag, I would prefer to find one at end of line, and to then position the cursor after the first *

?\*\zs[^*]\+\*$

Then yank as far as the next *

y/\*

This leaves the most recent "header tag" copied to the buffer, whence it can be pasted into (what I assume is) your WebHelp() function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.