Question

I'd like to know if there's a bundle or a preference somewhere in Textmate to get Sublime's white dotted column delimiter. Look at the screenshots.

Look at this PHP function in Textmate

textmate screenshot
(source: darwinsantos.com)

Now look at it in Sublime.

sublime screenshot
(source: darwinsantos.com)

If you take a close look notice that in Sublime the beginning and ending curly brace are bound by a white dotted line that let's you know that both curly braces are aligned in the exact same column.

Is there a way to get this in Textmate?

Was it helpful?

Solution

Update (5/2016): TextMate has gotten indent guides! As of version 2.0-beta.9.2 View->Show Indent Guides. They're a work in progress, but they are available.


Update: If you're able to get this working and are willing to build your own textmate via the official instructions, then you might have a crack a building (and maybe even contributing to) my fold guides enabled version of TextMate2. There are no builds, and it is not ready to be introduced into TextMate2 yet as it lacks a setting to disable the guides.


This is a feature in development, when complete it will be significantly more intelligent than what I'm about to describe. The new version, when it eventually comes out, will respect the indentation rules of the language, rather than simply filling in pairs of spaces/tabs.

That said, I've used this to ensure countless lines of templates are perfect.

The method is updated, but otherwise the same as described for Textmate1 by Cocabits.

You will end up with something like this: fold guide demo Note the second to last line, lacking the white space to trigger the lines. The new version will be much closer to Sublime's

First we are going to need to teach TextMate how to identify the tabs and spaces which we use before each line of code.

I have created a fold guides bundle however this is the first time I've given it out and I am terrified it just won't work for you, that said give it a try.

If it doesn't work, you will need to manually add these rules, I will show you how to make it its own bundle, but you could add it directly to any language you like.

Create a bundle from Bundles->Edit Bundles, then, File->New, select bundle and give it a name, then File->New and make a grammar. The grammar should have this code:

{   patterns = (
        {   include = '#leading-spaces'; },
        {   name = 'meta.leading-tabs';
            begin = '^(?=\t)';
            end = '(?=[^\t])';
            patterns = (
                {   match = '(\t)(\t)?';
                    captures = {
                        1 = { name = 'meta.odd-tab'; };
                        2 = { name = 'meta.even-tab'; };
                    };
                },
            );
        },
    );
    repository = {
        leading-spaces = {
            begin = '^(?=\s\s)';
            end = '(?=[^\s\s])';
            patterns = (
                {   match = '(\s\s)(\s\s)?';
                    captures = {
                        1 = { name = 'meta.odd-tab'; };
                        2 = { name = 'meta.even-tab'; };
                    };
                },
            );
        };
    };
}

And the inspector should look like this:

grammar with injector set to *

Now we just need a theme rule to match 'meta.even-tab' and or 'meta.odd-tab', so just add this to your current theme:

{name = 'Alternating Tabs';
    scope = 'meta.even-tab';
    settings = {
        background = '#232323';
        };
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top