-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:mvnural/sublime-indent-respectful…
…-sort
- Loading branch information
Showing
1 changed file
with
57 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,57 @@ | ||
# sublime-indented-sort | ||
Sublime Text plugin that provides sort functionality while respecting the indented block structure | ||
# 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. | ||
|
||
1. Open the Python console by pressing ``Ctrl+` `` or by selecting View | Show Console in the menu. | ||
2. Type `view.run_command("indent_respectful_sort")` and hit `Enter` to run `IndentRespectfulSort` with default options (tab delimited). | ||
3. 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") | ||
|
||
# Installation | ||
1. Create a folder named `IndentRespectfulSort` in the sublime packages folder. | ||
2. Simply extract the contents of this repository into the newly created `IndentRespectfulSort` folder. | ||
|