Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal links (headers) #436

Open
Hipomenes opened this issue Sep 4, 2022 · 2 comments · May be fixed by #452
Open

Internal links (headers) #436

Hipomenes opened this issue Sep 4, 2022 · 2 comments · May be fixed by #452

Comments

@Hipomenes
Copy link

Hipomenes commented Sep 4, 2022

I just can't make the internal link navigation work. I've enabled both the hypertext and keyboard modules, and tried to set a localeader key, and still no success. My internal links look like this:

[[#architecture]]

And the corresponding header:

# Architecture

@fmoralesc
Copy link
Member

IIRC, the code for link navigation requires that you specify the anchor in the heading explicitly (it does not keep track of automatically generated anchors). So what happens if you change the heading to this?

# Architecture {#architecture}

@Hipomenes
Copy link
Author

Hipomenes commented Sep 5, 2022

Thanks for your quick response! The problem with this, beyond adding redundancy to headers, is that it might be difficult to add multiple links to the same anchor (unless you are suggesting that an specific syntax be followed).

I think this would be a great feature to have. Looking around I found that vim-markdown has an elegant solution for this:

g:vim_markdown_follow_anchor

This feature allows the ge command to follow named anchors in links of the form file#anchor or just #anchor, where file may omit the .md extension as usual. Two variables control its operation:

let g:vim_markdown_follow_anchor = 1

This tells vim-markdown whether to attempt to follow a named anchor in a link or not. When it is 1, and only if a link can be split in two parts by the pattern '#', then the first part is interpreted as the file and the second one as the named anchor. This also includes urls of the form #anchor, for which the first part is considered empty, meaning that the target file is the current one. After the file is opened, the anchor will be searched.

What do you think?

Thanks!
d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants