Allow to follow named anchors with ge
I've submitted a PR for this https://github.com/plasticboy/vim-markdown/pull/312, see the detailed description of the change in the commit message.
I would like to further motivate this change: it goes one step beyond in turning vim-markdown into a personal wiki option. I couple the ability to follow named anchors and the ability to autocomplete the elided .md extension with additional syntax for wiki-links:
syntax region mkdLink matchgroup=mkdDelimiter start='\[\[' end='\]\]'
\ contains=mkdURL oneline keepend concealends
syntax match mkdURL /[^]]*\]\]/ contained
Maybe you can add this syntax, disabled by default, with an option to turn it on.
Besides, I've improved the filename logic, this is the comment for the (second) commit:
Allow local anchors and improve buffer filename.
Now urls of the form #anchor works (by searching the -transformed-
anchor in the current buffer).
I've fixed the new buffer file naming code in two senses (and note that
both are unrelated to named anchors, but since the problem it's in the
same part of the code I decided to include the fix here):
1. The previous code only expanded the filename relative to the current
file when vim_markdown_no_extensions_in_markdown was set, but
concatenation of .md is unrelated to filename expansion.
2. The previous code was expanding relative to the home dir (:~) then
making the path absolute (:p), which made not much sense and also
produced long, absolute, buffer names. Now the full path is computed
relative to the current file but the buffer is named relative to the
current working directory (:.).
Is there an example of using this functionality somewhere? If I have the following 3 lines of markdown:
[test](#this-is-a-test)
# blah blah
# This is a test
then type 'ge' from inside the link on line 1, the cursor jumps to the opening bracket of [test], when it should, of course, jump to line 3, correct?
After further review, it appears that I can make the above example work by changing line 1 to:
[test](#This is a test)
or even:
[test](#this is a test)
It's my understanding that spaces are supposed to be replaced with hyphens in these links. Is this incorrect?
I can't follow anchors with ++g-e++ but it doe's open the actual files for me when I do an anchorless link ++g-e++ . did it get fixed for nvim or something? or how do you set anchor following for nvim?
in my case the first ge moves the cursor to the link text (#this is a test) and another ge moves it to the actual heading.
Further typing ge creates a new file with that name.