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

Indent To Parenthesis

by rchl ALL

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

Details

Installs

  • Total 2K
  • Win 1K
  • Mac 421
  • Linux 401
Jan 15 Jan 14 Jan 13 Jan 12 Jan 11 Jan 10 Jan 9 Jan 8 Jan 7 Jan 6 Jan 5 Jan 4 Jan 3 Jan 2 Jan 1 Dec 31 Dec 30 Dec 29 Dec 28 Dec 27 Dec 26 Dec 25 Dec 24 Dec 23 Dec 22 Dec 21 Dec 20 Dec 19 Dec 18 Dec 17 Dec 16 Dec 15 Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2
Windows 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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.