ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Indent To Parenthesis

by rchl ST2/ST3

Sublime Text plugin for better auto-indenting of function arguments on breaking lines

Details

Installs

  • Total 662
  • Win 370
  • OS X 147
  • Linux 145
Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28 Mar 27 Mar 26 Mar 25 Mar 24 Mar 23 Mar 22 Mar 21 Mar 20 Mar 19 Mar 18 Mar 17 Mar 16 Mar 15 Mar 14 Mar 13 Mar 12 Mar 11 Mar 10 Mar 9
Windows 0 0 1 0 0 3 0 0 0 1 0 1 0 0 1 0 0 0 3 1 0 2 0 0 0 0 0 3 0 1 0 1 1 1 0 0 0 0 0 1 0 0 1 1 0 1
OS X 0 0 1 0 0 0 0 1 1 1 0 0 0 1 0 0 1 1 0 0 1 2 0 0 1 0 0 2 0 0 0 1 0 0 1 1 0 0 0 0 1 1 0 0 0 0
Linux 0 0 0 0 0 2 0 2 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 2 0 1 0 1 0 1 0 0 1 0 0 0

Readme

Source
raw.​githubusercontent.​com

Indent to parenthesis Sublime Text package

As I was dissatisfied with Sublime's indent_to_bracket option, I've created my own implementation that behaves in a smarter way.

The general idea is to indent arguments in a function call to the opening bracket so that:

function Foo(arg1,<enter>

aligns caret following way:

function Foo(arg1,
             |

Caveat: Currently this package only works when using spaces for indentation (translate_tabs_to_spaces setting is true). I don't code with tabs so I'm probably not gonna spend time to make it work with tabs. If you care, please submit a pull request.

Why is it better than built-in functionality?

For example, with code like this:

function(arg1, arg2) {}

when wanting to break the arguments into two lines (because line is too long, for example), one would put the caret after the comma and press enter.

Built-in functionality would break them incorrectly, leaving this result:

function(arg1,
 arg2) {}

while this package will align it correctly:

function(arg1,
         arg2) {}

Built-in functionality aligns code properly when placing cursor after the space (that follows the comma), but then it leaves trailing space on the line. This package handles both cases properly.