Giter Club home page Giter Club logo

sublime-sortlinesbyselection's Introduction

Selection Sorter

Did you ever want to sort some class members via their names, easily, or a number of lines via a string in the middle? Well, now you can.

This plugin enables you to sort lines by the text you have currently selected.

Default Commands

It ships with two commands you can find in the command palette:

  • Sort Lines by Selection
  • Sort Lines by Selection (Case Sensitive)

Customization

The plugin supports custom morphing of the selected strings before sorting, via little python snippets. For example you could reverse the string which is used for sorting, sort via the last character, only via the first etc..

You can make your custom sort available by creating a Default.sublime-commands file in your packages/user folder, or alternatively a keybinding which executes the command.

Example

Here a little example for a custom line sort:

Default.sublime-commands

    [
        {
            "caption": "Sort Lines by Selection",
            "command": "sort_lines_by_selection",
            "args": {
                "morph": "s[::-1]" // This will reverse the string
            }
        }
    ]

As you can see I reference a variable s (a string) and reverse it. This would sort the lines by the reversed selection. So a line with a selection of "AZZZZ" would be at the bottom, rather than at the top.

Note however that only a single statement is allowed, otherwise your custom morph will not work.

Technically speaking the morph argument is the "body" of a python lambda, and will be used as the key argument of the built-in sorted function.

Happy sorting!

sublime-sortlinesbyselection's People

Contributors

sascha-wolf avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.