Sublime Forum

ST3 Groovy Reindent issue

#1

hi All,

I am new in sublime text 3 and I ran into this re-indent issue in groovy coding.

def flag = false;

if (flag) {
    println "good";
} else {
   println "bad";
}

if I highlight the whole section, and perform a re-indent, it result will be:

boolean flag = false;

if (flag) {
    println "good";
    } else {
     println "bad";
 }

However, if the “else” is on its own line, then it seems to work perfect. I do want to have the else in the same line as the close curly bracket of the if.

Anyway I can re-configure this to make it works that way I prefer? Thanks!

0 Likes

#2

Interesting, the Groovy package doesn’t seem to have any indentation rules metadata, so it falls back to the ones in the Default package, which are just based on curly braces, and thus it doesn’t handle } else { correctly.

Please can you log an issue at https://github.com/sublimehq/Packages/issues


If you want to have a go at defining the regular expressions for it yourself, http://docs.sublimetext.info/en/latest/reference/metadata.html#indentation-options-children-of-settings is worth reading. Take a look at the Default indentation rules or the rules for the other languages for examples :slight_smile:

0 Likes

Sublime Text 3 re-indent broken
#3

I got a hack to this issue. I extracted the two Indentation* files from the Java.sublime-package, open them in an editor(sublime of course) and replace “java” to “groovy” and added these modified Indentation* file into the Groovy.sublime-package.

0 Likes