Skip to content

aravindparappil46/reorder-lines-by-length

Repository files navigation

Reorder Lines By Length Plugin

IntelliJ plugin to reorder selected lines by their length!
Reduce cognitive load and make your code look pretty!

Example

Before

this.queryBuilder = queryBuilder;
this.dao = dao;
this.validator = validator;
this.mapper = mapper;

After

this.dao = dao;
this.mapper = mapper;
this.validator = validator;
this.queryBuilder = queryBuilder;

How To Use

  • Select the lines of text you want to reorder
  • Right click and choose Reorder Lines By Length

What does it do?

  • Grabs the selected text
  • Splits them into an array by the new-line character
  • Sorts the array by ascending order of string length
  • Replaces selected text with the sorted text
  • Indents the selected text as well, so that everything looks neat!

Disclaimer

  • Please note that this will work only for groups of single lines i.e., the selected text should not contain any code that spans more than a single line

    For example, the below snippet of code cannot be formatted.
// This will break since the code spans more than one line
Caret primaryCaret = editor.getCaretModel() 
        .getPrimaryCaret();
  • Also, please make sure to select entire lines i.e., starting from the first character till the last!

About

IntelliJ plugin to reorder lines based on their length!

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages