Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Reorder Lines By LengthNew to Visual Studio Code? Get it now.
Reorder Lines By Length

Reorder Lines By Length

Aravind Parappil

|
1,319 installs
| (1) | Free
Reduce cognitive load and make your code look pretty!
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Reorder Lines By Length Plugin

VSCode 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.x = x;
this.mapper = mapper;

After

this.x = x;
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
  • Formats 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 used with this plugin.
// Reordering this will break, since the code spans more than one line
let lines = selectedText
    .split('\n')
    .filter((line) => line)
    .map((x) => x.id = 6);
  • Also, please make sure to select entire lines i.e., starting from the first character till the last!
  • IntelliJ plugin also available!
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft