Sublime Forum

Customise Javascript indentation

#1

I’m using ST4 Stable build 4169 with the default Javascript syntax. I’m finding the ‘deindentation’ of the default keyword really irritating when creating, for example, Vue props:

defineProps({
  meaning: {
    type: Number,
  default: 42,
  }
})

I’m assuming default is getting deindented because it’s expected in a switch() block. But it’s not a keyword here, and I rarely use switch(), so I’d like to disable this. But no idea really where to start on this. Is it even possible to customise this via preferences? Can I get the JS syntax definition and create a custom one without this ‘feature’?

1 Like

#2

If you install https://www.packagecontrol.io/packages/OverrideAudit, and then in the Command Palette choose the OverrideAudit: Open Resource entry, then browse to the JavaScript package, you’ll see a file there called something like Indentation Rules.tmPreferences. As you never really use switch statements, you can edit that to remove the default: part from the deindentation regex pattern and save it.

0 Likes

#3

Thank you! I did have OA installed already as I’d played with something years ago, but really only for checking when upgrades might have clobber things. I should go read the full docs for it, as this was really simple once I knew how :).

0 Likes