Indent Respectful Sort
Sublime Text plugin that provides sort functionality while respecting the indented block structure
Details
Installs
- Total 1K
- Win 683
- Mac 413
- Linux 245
Feb 26 | Feb 25 | Feb 24 | Feb 23 | Feb 22 | Feb 21 | Feb 20 | Feb 19 | Feb 18 | Feb 17 | Feb 16 | Feb 15 | Feb 14 | Feb 13 | Feb 12 | Feb 11 | Feb 10 | Feb 9 | Feb 8 | Feb 7 | Feb 6 | Feb 5 | Feb 4 | Feb 3 | Feb 2 | Feb 1 | Jan 31 | Jan 30 | Jan 29 | Jan 28 | Jan 27 | Jan 26 | Jan 25 | Jan 24 | Jan 23 | Jan 22 | Jan 21 | Jan 20 | Jan 19 | Jan 18 | Jan 17 | Jan 16 | Jan 15 | Jan 14 | Jan 13 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Windows | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | 0 |
Mac | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Linux | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
Readme
- Source
- raw.githubusercontent.com
About
Indent Respectful Sort is a Sublime Text plugin that provides sort functionality while respecting the block structure defined by indendation.
You may find this plugin useful when you have a consistently indented (all tabs or all 4 spaces etc.) file and would like to sort logical blocks (methods, classes or unordered lists) while maintaining inner structure of the blocks.
Note that this approach would only work in cases where indentation is not only present for readability but also for dictating the structure.
Usage
Using predefined commands
Open command palette by typing Ctrl + Shift + P
and start typing IndentRespectulSort
to use one of the predefined sort options.
As an example, running Indent Respectful Sort: Indented by 2 Spaces & Max Depth = 2 command on the below snippet
First Level Item 5
Second Level Item 2
Second Level Item 3
Second Level Item 1
Third Level Item 3
Third Level Item 1
Third Level Item 2
First Level Item 2
Second Level Item 2
Third Level Item 2
Third Level Item 1
Second Level Item 1
would yield the following.
First Level Item 2
Second Level Item 1
Second Level Item 2
Third Level Item 2
Third Level Item 1
First Level Item 5
Second Level Item 1
Third Level Item 3
Third Level Item 1
Third Level Item 2
Second Level Item 2
Second Level Item 3
Running a custom sort command
You may run IndentRespectfulSort
directly from the console if you need custom sort options.
- Open the Python console by pressing
Ctrl+`
or by selecting View | Show Console in the menu. - Type
view.run_command("indent_respectful_sort")
and hitEnter
to runIndentRespectfulSort
with default options (tab delimited). - You may specify arguments in the second parameter of the run command. Eg.
view.run_command("indent_respectful_sort", {"indent": " ", "maxDepth": 2})
Args
- maxDepth: Do not sort blocks beyond levels specified by this argument. (default: unlimited)
- onlyDepth: Only sort the blocks in the level specified by this argument. If onlyDepth is specified, then maxDepth is ignored. (default: None)
- indent: Specify the indentation used in this file. (default: “\t”)
Adding a custom sort command to Command Palette
- Open your user command palette file. It will be located in your Packages directory, see: http://docs.sublimetext.info/en/latest/basic_concepts.html, at Packages/User/Default.sublime-commands.
- Follow instructions here for adding new items: http://docs.sublimetext.info/en/latest/reference/command_palette.html
Example:
{
"caption": "Alphabetize i18n",
"command": "indent_respectful_sort",
"args": {"onlyDepth": 3}
}
Installation
Using Package Control
IndentRespectfulSort can easily be installed via Package Control.
- Make sure Package Control is installed. (See https://packagecontrol.io/installation).
- Press
ctrl + shift + p
(Win, Linux) orcmd + shift + p
(OSX) to open command palette. Find and selectPackage Control : Install Package
and hitEnter
. - In the newly opened panel, start typing
IndentRespectfulSort
and hitEnter
after you have found and selected. - Done!
Manual Installation
- Create a folder named
IndentRespectfulSort
in the sublime packages folder. - Simply extract the contents of this repository into the newly created
IndentRespectfulSort
folder.
Statistics
Available on the Package Control website. See https://packagecontrol.io/packages/Indent%20Respectful%20Sort
Bugs / Feature Requests
You may create a new issue at https://github.com/mvnural/sublime-indent-respectful-sort/issues