Share link with Line Number

Other services including will change the URL bar to allow sharing of not only a specific file, but also the line number and which character your cursor is on that line. They will also have scroll position for all open files.

If you have text highlighted, it will also include that in the URL.

All of this means you can share a link with a very similar view of what you were seeing when you made the link.

SEO: Link href anchor hook

2 Likes

This still doesn’t happen by default, and you can’t highlight subsections of the code or the line, or select multiple lines… but it is somewhat supported, in the most limited case, a single line, a single file

#src/index.ts:10

You have to know about and remember the feature and how it’s implemented… everyone does it differently

Other implementations

  • CSB: ?file=/index.js:34671-34680
    • They use character numbers, allowing you to select blocks and sub sections of the file, as well as multi-select and select in multiple files.
  • SB: ?file=src%2Findex.ts%3AL10
    • Doesn’t update in real-time, you have to click the line to highlight it
1 Like