Sublime Forum

Highlight scope

#1

Highlight the scope/guide at the cursor position. This will make it alot easier to see where a scope starts and ends. Image should explain it all.

(I don’t know if this has already been suggested)
(The code in the image example is from the SublimeREPL plugin if anybody wondered (not mine))


0 Likes

#2

Who wrote that crap? :open_mouth:

0 Likes

#3

i love this idea!

0 Likes

#4

[quote=“wuub”]

Who wrote that crap? :open_mouth:[/quote]

That’s off topic really. It’s not supposed to be any code in particular, just illustrate some random code. For the record and awesome plugin (and this is probably the messiest part of it). But let’s try to stay on topic!

Edit: Lol. Just realized it’s you. Hehe. Great work on that plugin. Keep it up. :stuck_out_tongue:

0 Likes

#5

I really like this idea for Python, but it clashes somewhat with indent_guide_options when set into “draw_active” mode.

 "indent_guide_options": "draw_normal", "draw_active"] 

0 Likes

#6

[quote=“wuub”]I really like this idea for Python, but it clashes somewhat with indent_guide_options when set into “draw_active” mode.

 "indent_guide_options": "draw_normal", "draw_active"] 

Hmm. I’m still new to sublime, so I wasn’t aware of that feature. It seems to do pretty much the same thing as what I suggested…? (except without customizable color?)

0 Likes

#7

It does something similar to what you proposed (at least for python), but not quite. There is a non-trivial difference between “scope” (or “block” or “compilation unit” or “function” or whatever is the correct term for any given language) and indentation level.
It’s pretty difficult to read indentation wrong, but scope is super easy to misread:

if (guard)
   action1();
   action2();

I don’t exactly know what problem “active” indent guides are solving and have them turned off. Couldn’t stand constant flickering.

0 Likes

#8

The goal must be to quickly see where a scope ends. When reading through some code, it’s easy to miss where one function definition begins and another ends when the function/file gets big.

Improvement to the current active_guides so the color can be customized is basicly what I’m looking for/suggestion i guess. Currently, it falls between two chairs: not being visible enough to be of much help when going through code quickly, and being constantly “flickering” which distracts its users.

Perhaps a solution like the word highlight feature could be implement. So that when you highlight the scope-opener line, it will highlight it’s indent all that way. Or perhaps make a hotkey, so when you press something like ctrl+i, it shows where the “if” ends etc?

0 Likes

#9

Open a theme file that you’re using (for example /sublime-text-2/Packages/Color Scheme - Default/Monokai.tmTheme) and edit this:

<key>activeGuide</key> <string>#FF0000</string>

0 Likes