Sublime Forum

Indent Guides

#35

Eugh, I hate it when plugins stop working because someone added a new setting. Such a pain. Personally, I think it is really weird and annoying that most plugins in sublime default to being off. Why would I install a plugin if I didn’t want to use it. Plugins should default to being on.

You need parentheses on line 166. You could have a situation like not True and False which is interpreted as (not True) and False but you want not (True and False) so that it gets in the if.

Also, I don’t like that when I select text, all indent guides go away. I actually used that a good bit in my 76 space indent to select the correct text.

0 Likes

#36

It was 2 in the morning and I was just hacking a bit with what was there.

That refresh only needs to be run when self.guides is empty and self.loaded is True. It was a quick hack to get it working around that odd bug I explained earlier.

I’ll play around with it a bit more and add it as an option and try and cleanup my mess a bit :s

0 Likes

#37

Heh, yea, it’s cool.

The thing I’ve noticed is that it can be a little slow. It’s because of the way regions are done in sublime. What we end up doing is redrawing ALL of the guides every time I type or move the cursor in any way. That is causing lag. I think we need to either a: remove that option or b: move that code to run in a timer so it doesn’t lag while i am typing. In a 5,000 line file, it might add like 20k regions to it. We are iterating through each of them every time and replace all the regions every time the selection changes.

0 Likes

#38

If we could capture when the view changes, we could do it only in the current viewable area. Or if we could capture what changes in the buffer, we could only update lines that change.
Because neither of these things is possible at the moment, I just only edit small files. :stuck_out_tongue:
Seriously though, a timer’s probably a good idea. I might look into doing that over the weekend.

0 Likes

#39

There’s a half decent implementation of a timer here (it executes a callback .1 seconds after the most recent call to on_sel_modified) github.com/ajpalkovic/SublimePl … edFiles.py

0 Likes

#40

Thanks for the update.

There is any way of setting the highlight color other than editing the theme file? Like a setting or something?

0 Likes

#41

Not really, you basically have to edit the theme.

0 Likes

#42

I updated mine with a couple changes. I merged Anomareh’s changes, crudely disabled hiding indent guides in selections and changed it to use dicts instead of lists for cursor positions.

More importantly, for showing the active guide, it now uses the end of whitespace for the line instead of the cursor position. The idea is that if I type , as I am typing, I still want the active indent guide to show up at the beginning of the line, not at the end of , doesn’t really make sense there.

0 Likes

#43

Alright, I got around to rewriting it.

gist.github.com/1136448

It’s bug free as far as I can tell. I don’t think it’s possible to make it really friendly with large files past a timer which I personally find kind of meh. For it to get any better it probably just has to be implemented internally.

Quick run down of the options:

[code]‘indent_guides_enabled’: true
Enables indent guides.

‘indent_guides_max_file_characters’: 524288
The max file size a file is allowed to be and have indent guides.

‘indent_guides_scope’: ‘comment’
The scope name assigned to guides.

‘indent_guides_active_scope’: ‘indent_guides_scope’
The scope name assigned to active guides.

[NOTE] To enable active guides you have to set this option. Active guides
       default to the same scope as inactive guides.

‘indent_guides_hide_in_selection’: true
Indent guides will be hidden within selections.

‘indent_guides_hide_on_line’: true
Indent guides will not be drawn on the current line.

[NOTE] This only applies to empty selections.

‘indent_guides_active_wrap_to_text’: true
If true, the active guide will always be the deepest guide on the cursor’s line.
If false, the active guide will be the guide closest to the left of the cursor.[/code]

0 Likes

#44

@Anomareh, working great for me! Thanks a lot!

0 Likes

#45

@pod Great :]

Also, I just updated it (same link as before gist.github.com/1136448). Fixed a bug when interacting with the console and also added a check to disable the built-in guides if they’re enabled alongside the plugin.

0 Likes

#46

[quote=“Anomareh”]@pod Great :]

Also, I just updated it (same link as before gist.github.com/1136448). Fixed a bug when interacting with the console and also added a check to disable the built-in guides if they’re enabled alongside the plugin.[/quote]

So, is this plugin already part of dev build 2104?

"Build 2104
Release Date: 24 August 2011
Added indentation guides. These may be disabled with the draw_indent_guides setting.

"

0 Likes

#47

Is this plugin already part of sublime in dev build 2104?

Because it tells this:

Build 2104
Release Date: 24 August 2011
Added indentation guides. These may be disabled with the draw_indent_guides setting.

0 Likes

#48

Partly yes. The active indent guides are not in 2104. If they aren’t made into a native feature I’ll just pull them out into a separate plugin.

0 Likes

#49

What ajpalkovic said.

The gist also has a few extra options the built-in guides don’t have (active guides aside). Namely the ability to toggle whether they are shown in selections or on the current line. Also the built-in guides will not show the last guide on a line that contains nothing but whitespace, the gist will. For example, if a line consists of nothing but 4 tabs, the built-in guides will only draw 3 guides ignoring the last one where as the gist will draw 4.

0 Likes

#50

[quote=“Anomareh”]
The gist also has a few extra options the built-in guides don’t have (active guides aside). Namely the ability to toggle whether they are shown in selections or on the current line. Also the built-in guides will not show the last guide on a line that contains nothing but whitespace, the gist will. For example, if a line consists of nothing but 4 tabs, the built-in guides will only draw 3 guides ignoring the last one where as the gist will draw 4.[/quote]

I find this functionality to be worth using the plugin over the default guides, thanks :smile:

0 Likes

#51

No problem, glad someone else can make use of it :]

I also forgot to mention there is also the ability to make the active guide wrap to text. If it’s set to wrap, regardless of the cursor position on the line, the active guide will always be the guide furthest to the right on the line. If it’s set to not wrap, the guide closest to the left of the cursor will be the active guide.

0 Likes

#52

@Anomareh very cool, thank you again! Is it possible to make guide dotted?

0 Likes

#53

Currently not, the ability to draw dotted regions is exposed to the api. As soon as it’s added though I’ll be adding it the plugin.

0 Likes

#54

As anyone noticed a change since two builds ago? I’m currently on 2139 and at some point I was very satisfied with the built-in indent guides.
Now they somehow don’t follow the tab size properly, drawing 2 guides instead of 4 in the example below:
link.olivierlacan.com/BV0C

Here are the settings I’m currently using.

      "auto_indent": true,
      "font_face": "Inconsolata",
      "font_size": 17.0,
      "line_padding_bottom": 1,
      "line_padding_top": 1,
      "translate_tabs_to_spaces": true,
      "tab_size": 2,
      "use_tab_stops": true,
      "trim_trailing_white_space_on_save": true,
      "draw_indent_guides": true
0 Likes