url link to multiple lines with #cl-XX-YY (BB-11586)

Issue #10622 resolved
John Theodore Goetz
created an issue

I would like to link to and highlight a block of code as opposed to a single line. Example: https://bitbucket.org/[user]/[repo]/src/tip/file.py#cl-10-20 which would link to line 10 and highlight lines 10 through 20. GitHub example

This is an extension of issues #8760 and #444

Comments (35)

  1. Lee Hambley

    I agree too, shame this doesn't work, often I'm tweaking the URL that way anway, and whoever I'm linking too knows to expect that feature, and they're just checking the URL to find what offset I wanted to reference.

  2. Daniel Tao staff

    Guess what? We're actually going to be shipping this little enhancement in the next week or so.

    I know, I know... long time coming for a simple request. In our defense, though, @s shaw, the issue from 2009 you're referring to has been resolved for quite some time (that one was asking for single-line highlighting, which we've had for ages).

    Anyway, I'll update this ticket once the feature's live.

  3. Steven Brown

    Just incase no one knew and need to highlight a block of code for the mean time you can append lines to the end of your URL with a comma in-between each line. file_name.ext-193,194,195,196,197,198,199,200 this would highlight from 193-200. I know it's more work but is a good work around ATM.

  4. Daniel Tao staff

    @Steven Brown What you've happened across is actually a work in progress. We're still working on getting the UX right; but in the meantime, yes you can highlight ranges of lines by directly modifying the URL. As for the workaround you suggested: you actually don't need all of those commas! You can use a colon; e.g., to highlight lines 193–200 of file_name.ext: #file_name.ext-193:200.

  5. Daniel Tao staff

    @Steven Brown Unfortunately I can't really make any promises—there's always a chance that something will come up that causes us to feel it's worth changing the syntax (esp. given we haven't really announced this yet, aside from this issue!)—but my honest guess is that no, it's not likely to change.

  6. Daniel Tao staff

    We now allow you to select a range of lines in our source view. Even multiple ranges! The URL syntax is #<filename>-<range1>,<range2>,... where the format for each range is <start>:<end>.

    See here, for example:


    You can also highlight a range by clicking a line number to the left of the file, then shift+clicking to expand the selection to a range. You can also cmd+click (on Macs) or ctrl+click (Windows/Linux) to add lines/ranges.

    We'll write up an announcement for this in our blog soon, but in the meantime I figured I'd just resolve this ticket and let people know.

  7. Eric Lubin

    Before calling this final, could you also make the page JUMP to the highlighted lines? just loading the page doesn't give the user any indication that lines are highlighted below....

  8. John Guidry

    Whoa, was helping patch vim-fubitive to use the updated #<filename>-<line> format and found this ticket. Fixing the scroll on load for ranges would make this perfect!

  9. Daniel Tao staff

    OK, honesty hour: I did implement the logic to scroll to the highlighted range as requested by @Eric Lubin and others. And then there was a small bug, and I reverted it, and then other stuff came up and I totally forgot about it.

    I am pleased/embarrassed to share that I have just resurrected this work (almost a year later!) and have a pull request open to get it back in. Hopefully it'll be shipped in the next week or so.

    Better late than never, right?

  10. Log in to comment