Sublime Forum

Sublime Text 3 re-indent broken

#1

Hi,

using Sublime Text 3 a lot to edit TCL code. Since much of that code came was created in another editor, indentation is a mess like usual when switching editors due to the mix of tabs and spaces used to indent. Therefore, re-indent is an essential feature in my case. However, it is pretty much unusable when it comes to TCL.

Examples:

Sublime Text can’t handle ‘}’ with text following them. Code like this

if {test} {
bla
} else {
blabla
}

will be indented wrong, starting at “} else {”. And since indentation of a line is incrementally depending on the indentation of the previous line, all subsequent lines are wrong as well. This effect accumulates and makes code utterly unreadable.

Also, Sublime indentation is not agnostic to braces used in comments. So, if you comment out regular code, that will screw up indentation as well.

Pity, this is sorely missing.

Thanks,
gkoala

0 Likes

#2

it seems that the TCL package doesn’t define any indentation rules, so it uses the ones from the Default package, which also apply to comments:

the same has been said before of some other packages, the post here may help you to configure the indentation rules yourself:

0 Likes

#3

Thanks. What I understood is that I have to overwrite the indentation rules of the Default package if I want this to work. Not that I have any clue where and how to do that, but i guess I can figure that out.

But won’t that kill indentation for other languages? Isn’t it possible to overwrite the local TCL indentation rules?

BTW: I doubt that a simple regexp is able to express the complexity of proper code indentation… There’s many more situations:

continued expressions, e.g.

if {a || b || c ||
d || e || f} {
}

or quoted line breaks:

set x [someProcedure
-input file1
-output file2
]

0 Likes