Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Overload119/indent-sort

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

  • Uses the indentation from the first highlighted line.
  • Makes some assumptions about the indented code. Namely:
    • Newlines are preserved and kept in the same order.
    • Include single-character lines as part of the indentation block.

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}
/>

const Object = {
  getA() {
    return 'a';
  };

  getB() {
    foo();
    return 'b';
  };
};

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'

About

Atom plugin to sort with respect to indentation.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Morty Proxy This is a proxified and sanitized view of the page, visit original site.