Search code examples
javascriptsublimetextsublimetext3code-formattingauto-indent

Auto indent method chaining in Sublime Text 3


As I type the following javascript code (exact keystrokes):

myObject
.doSomething()
.doSomethingElse();

I'd expect it to automatically become the following...

myObject
    .doSomething()
    .doSomethingElse();

... as would any other programmer, right?

How do I enable this, and why isn't it enabled by default?


Solution

  • You can use Sublime Code formatter with support JavaScript/JSON Beautifier, this link will show you how to usage this plugin.

    Or another way is to insert your code inside Key Bindings - User file:

    {"keys": ["alt+shift+f"], "command": "reindent", "args": {"single_line": false}}