Sublime Forum

[Solved] How to break long <string> lines on Sublime Text Theme files?

#1

How to break long lines on Sublime Text Theme files?

On my theme files the lines are becoming bigger and bigger, so I though about breaking them like this:

    <dict>
        <key>name</key>
        <string>Keyword Common</string>
        <key>scope</key>
        <string>keyword.common, constant.language.python, storage.type.function.python,
                keyword.control.import.python, storage.type.class.python,
                keyword.control - meta.preprocessor, entity.name.tag, punctuation.definition.tag,
                keyword.desktop, keyword.mathematics, meta.diff.range, keyword.operator.word</string>
        <key>settings</key>
        <dict>
            <key>fontStyle</key>
            <string>bold</string>
            <key>foreground</key>
            <string>#0000FF</string>
        </dict>
    </dict>

But it is not working, the scopes are being ignored, and only with everything in one line is being accepted by Sublime Text:

    <dict>
        <key>name</key>
        <string>Keyword Common</string>
        <key>scope</key>
        <string>keyword.common, constant.language.python, storage.type.function.python, keyword.control.import.python, storage.type.class.python, keyword.control - meta.preprocessor, entity.name.tag, punctuation.definition.tag, keyword.desktop, keyword.mathematics, meta.diff.range, keyword.operator.word</string>
        <key>settings</key>
        <dict>
            <key>fontStyle</key>
            <string>bold</string>
            <key>foreground</key>
            <string>#0000FF</string>
        </dict>
    </dict>
0 Likes

#2

Since this is a huge OR block, you could always just add another dict with the other half of the scope selectors.

Or use https://packagecontrol.io/packages/CSScheme, which collapses line breaks in the source file.

0 Likes

#3

or just turn on word wrap for tmTheme files :wink:

0 Likes

#4

Thanks y’all, the best here seens just to enable the line wrap for tmTheme files. But just to know, is there not problems as maximum line width as 512 chars for theme files right?

0 Likes

#5

where did you get this information from? I’m not saying it isn’t true - I haven’t tried it - I just never heard about it before…

0 Likes

#6

I was just wondering it, but thinking better, it would not make sense probably.

0 Likes

#7

I found out how to break long lines on theme files. Just do them like this:

        <dict>
            <key>name</key>
            <string>Keyword Operator</string>
            <key>scope</key>
            <string>
                , keyword.operator - meta.preprocessor,
                , keyword.brackets,
                , punctuation.definition.parameters,
                , punctuation.definition.arguments,
                , punctuation.definition.inheritance,
                , punctuation.definition.group - meta.preprocessor,
                , punctuation.definition.block - meta.preprocessor,
                , punctuation.definition.brackets - meta.preprocessor,
                , punctuation.terminator - meta.preprocessor,
                , punctuation.accessor - meta.preprocessor,
                , punctuation.separator - meta.preprocessor,
                , punctuation.definition.parens,
            </string>
            <key>settings</key>
            <dict>
                <key>fontStyle</key>
                <string>bold</string>
                <key>foreground</key>
                <string>#000080</string>
            </dict>
        </dict>
0 Likes

#8

On new Sublime Text version, the syntax changed to this:

<dict>
    <key>name</key>
    <string>Punctuation</string>
    <key>scope</key>
    <string>markup.list
        , variable.parameter.function
        , punctuation.definition.image
        , punctuation.definition.variable
        , punctuation.definition.parameters
        , punctuation.definition.array
        , punctuation.definition.metadata
    </string>
    <key>settings</key>
    <dict>
        <key>foreground</key>
        <string>#373b41</string>
    </dict>
</dict>
0 Likes