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

Align Arguments

by denniskempin ST3

Sublime Text 3 Plugin to automatically format and align argument lists on the opening bracket

Labels formatting

Details

Installs

  • Total 40K
  • Win 29K
  • OS X 7K
  • Linux 4K
Jun 18 Jun 17 Jun 16 Jun 15 Jun 14 Jun 13 Jun 12 Jun 11 Jun 10 Jun 9 Jun 8 Jun 7 Jun 6 Jun 5 Jun 4 Jun 3 Jun 2 Jun 1 May 31 May 30 May 29 May 28 May 27 May 26 May 25 May 24 May 23 May 22 May 21 May 20 May 19 May 18 May 17 May 16 May 15 May 14 May 13 May 12 May 11 May 10 May 9 May 8 May 7 May 6 May 5 May 4
Windows 15 18 16 40 40 48 35 37 30 24 36 17 49 37 45 20 29 41 74 24 45 38 20 23 37 40 51 33 41 18 31 48 41 50 44 42 24 32 44 50 52 45 32 22 24 31
OS X 4 2 5 8 5 7 5 6 5 4 7 2 6 7 6 2 2 7 10 6 6 6 4 2 7 6 5 8 3 3 5 4 10 6 5 4 5 4 8 18 6 8 5 4 1 4
Linux 4 3 0 1 0 8 10 3 2 3 9 4 7 7 3 0 6 3 6 14 2 8 1 5 3 8 9 4 3 3 6 2 1 5 8 7 1 4 7 4 2 7 6 6 3 2

Readme

Source
raw.​githubusercontent.​com

align-arguments

Sublime Text 3 Plugin to automatically format and align argument lists on the opening bracket

Many style guides require that argument lists are formatted in the following way:

ReturnType ClassName::ReallyLongFunctionName(Type par_name1, Type par_name2,
                                             Type par_name3) {
  DoSomething();
  ...
}

With the argument list lining up with the opening parenthesis. This can be tedious to format when renaming functions with a long list of arguments, which is why this plugin exists. It provides two commands. Place the cursor inside an argument list like this one

ReturnType ClassName::ReallyLongFunctionName(Type par_name1, Type par_name2, Type par_name3) {

“Format Argument” will reformat the list of arguments and wrap the line if it exceeds the maximum line length (80 by default). The output will be matching the requirement above.

Alternatively you can run wrap lines yourself and let it just do the indentation with the “Align Arguments” command on a snippet like this:

ReturnType ClassName::ReallyLongFunctionName(Type par_name1,
    Type par_name2,
    Type par_name3) {

Which will turn into:

ReturnType ClassName::ReallyLongFunctionName(Type par_name1,
                                             Type par_name2,
                                             Type par_name3) {

Configuration:

"align_arguments": {
  "line_length": 120,
  "one_per_line": true,
}

line_length: Maximum line length. Defaults to the first ruler on the current file, but can be overwritten with this parameter. one_per_line: When the argument list becomes too long for a single line, put each argument on a separate line. Default: false.