indent-sort

Sorts blocks of text with respect to indentation.

Overload119

1,535

2

0.5.0

MIT

GitHub

Indent Sort

A normal line sort can ruin the layout and syntax of indented code. This plugin aims to respect indentation while sorting, useful for sorting method names, or props of a React component.

Usage

Indent Sort

class Foo() {
  b() {
    func();
  }
  a() {
    func();
  }
}

def methodC:
  foo()
def methodA:
  foo()
def methodB:
  foo()

<Foo
  unsortedProp={{
    a: 1,
    z: 2,
  }}
  aFoo={2}
  bFoo={1}
/>

Will turn into:

class Foo() {
  a() {
    func();
  }
  b() {
    func();
  }
}

def methodA:
  foo()
def methodB:
  foo()
def methodC:
  foo()

<Foo
  aFoo={2}
  bFoo={1}
  unsortedProp={{
    a: 1,
    z: 2,
  }}
/>

keymap.json

'atom-workspace':
  'ctrl-6': 'indent-sort:sort'