Sublime Forum

Highlight bookmarked lines

#1

First of all, I absolutely adore Sublimetext2, and aside from Visual Studio (for C# ONLY), its pretty much the only edit I will use. One of my favorite features it the Bookmarking; I use it constantly. One thing I would like to be able to do, however, is highlight the background of lines which contain bookmarks. Much like the way the current caret line is highlighted (another feature I love), but using a color specifically for bookmarked lines. It would be great if these showed up in the minimap as well, but even if they didn’t, this would still be great.

Now, why did I post this in Plugin Development rather than Ideas & Suggestions? Well, mainly because, as I am a developer, I don’t mind putting in the work and making a plugin which does this myself (to be contributed back to the community, of course), but work and family demands mean I don’t have time to chase down a rabbit hole only to find out that I would not be able to accomplish this via the plugin API. So how about it? Is this something that I could mod in, or is this something that would have to be implemented at the source level?

0 Likes

#2

You could add a region to the edit and let this region have an outline, like SublimeLinter.

0 Likes

#3

I don’t think there’s a callback for bookmarking, so you’d either have to poll the view to see if the bookmarks have changed or wrap the bookmark commands. I’d recommend the latter method.
What I’d actually recommend, though, is this plugin:
github.com/colinta/SublimeMarkAndMove
It does its own bookmarking and adds some cool features on top. As a bonus, it also draws an outline around your bookmarks. I just changed all the bookmarking shortcuts to use Mark and Move instead of Sublime Text’s default bookmarks.
Changing the background color of an entire line (à la caret line highlighting) is unfortunately impossible with Sublime Text 2’s API; you can only change the background color of characters themselves, and then only to colors that are in the current color scheme.

0 Likes

#4

Sections of my code have a different background colour (or effect) across the full width of the view. This appears for css and php blocks within HTML files. How is this created, or is it in-built to ST?

0 Likes

#5

It’s built into your language grammar. If you want to modify the background color on the fly, you’d have to dynamically generate a language grammar to specifically target the section of code you’re interested in. It can be done—I think there’s a CSS color plugin that does it—but it’s a huge hassle.

0 Likes

#6

Thank you. If it was straight-forward I was actually thinking of deleting it :wink: although the ability to at least change the background colour would have been interesting.

I’ll leave it - it’s hardly noticeable (against my chosen background colour). Ta, Andy.

0 Likes

#7

It’s somewhere in the Color Scheme you use. Mine looks like this:

<dict> <key>name</key> <string>♦ Embedded Source &amp; Code in Markup</string> <key>scope</key> <string>text source, markup.raw</string> <key>settings</key> <dict> <key>background</key> <string>#B0B3BA14</string> </dict> </dict>

Note the “text source” which defines the selector and the “background” stuff (if you’re not used to tmThemes).

0 Likes

#8

Thank you @FichteFoll

I’d searched for this in my theme before but missed it because of the rgba setting:

<dict> <key>name</key> <string>♦ Embedded Source (Bright)</string> <key>scope</key> <string>text source</string> <key>settings</key> <dict> <key>background</key> <string>#B1B3BA08</string> </dict> </dict>
I might change it slightly now :sunglasses:

0 Likes

#9

Thanks for the replies everyone! A shame this can’t be done (at least, not cleanly/easily), but perhaps someday.

0 Likes

#10

Anyone know of anything new out there for Sublime3 that makes bookmarks more noticeable, or anything package?

thanks

0 Likes