9

Is it possible to jump to a line number with a markdown link in VSCode?

for example

| [/path/to/MyFile.ts](/path/to/MyFile.ts<---line-number) Jump to MyFile.ts line 123

Thanks.

gevik
  • 3,177
  • 4
  • 25
  • 28
  • Looks like was just fixed: https://stackoverflow.com/a/69824214/836330. Not sure if was broken sometime after the below answers??? – Mark Nov 03 '21 at 11:40

3 Answers3

13

Yes, use L123 as the link fragment. For example:

[/path/to/MyFile.ts](/path/to/MyFile.ts#L123)

[MyRelativeFile.ts](MyRelativeFile.ts#L123)
Matt Bierner
  • 58,117
  • 21
  • 175
  • 206
0

I think what you're looking for is an Anchor link.

https://gist.github.com/asabaylus/3071099

Dylan Wright
  • 1,118
  • 12
  • 19
  • I tried adding # at the end of the url but it does not work unfortunately. – gevik Jun 14 '18 at 15:05
  • Have you tried this? https://stackoverflow.com/questions/23821235/how-to-link-to-specific-line-number-on-github – Dylan Wright Jun 15 '18 at 18:11
  • If I followed correctly in that link, you'll see that if you go to your target file (MyFile.ts) and highlight the line you want it should update your URL. However when I tested this locally you actually have to select the number of the line you want. So within github select that line by clicking the number. If you 'Copy Permalink" it will give you what you want to link to – Dylan Wright Jun 15 '18 at 18:33
0

This appeared to be a bug is vscode. Which is fixed now. Thanks everyone for the answer.

gevik
  • 3,177
  • 4
  • 25
  • 28