A feature rich text sorter that takes indentation into account. This is a vscode extension to help sort text & lists in a scoped manner. It's part of a bigger project called scopedsort. Documentation and examples are mainly held there. Table of Contents
WhyVscode already provides commands for sorting
( Indentation AwarenessMost sorters do not keep track of indentation and sort line by line. This leads to some undesired sorts: This was the initial reason I created this extension, which is why it's called "scopedsort". Standardization & UtilityThis project is implemented on vscode, npm, the command line and a website. They all share the same options and output. A big part of this tool is sort-comments. I am not aware of any other project that allows for you to specify a section to repeatedly sort. OptionsThis extension has a lot of options, all of which can be used together (provided they don't conflict logically). Other extensions like tyriar.sort-lines have a reasonable amount of options, but they don't have a nice way to combine them, so they end up polluting the command contributions with 8+ commands. And even then they don't allow for all the possibilities. Some of the more extensive options this extension implements include: custom-sort-orders, sort-by-column, sort-by-regex, etc... This is one of the less valid points though, since you won't need these advanced options often. DisclaimerThis extension might have a bit of a learning curve and does require some reading. Most sorting cases can be solved with tyriar.sort-lines. This extension is not meant for sorting words inside a line, nor is it trying to sort language specific things like imports or properties of an object (although it can sort them if they have a simple structure). I am not a fan of adding extensions unless they are important, so I should also inform you of the other mediums this project has: (cli & website). This might serve better for most users. If you only need to sort text on occasions, the website has you covered. If you are sorting certain sections or files repeatedly, the cli tool might be better. It's quicker and more automatable. The only instances I see this extension being more efficient than the other
mediums is if you are sorting a lot of different text only once or if you are
using the helper command Demos / PreviewsCommand: Note this example is technically outdated since it uses Sort on save: If you want to see examples of how the program sorts certain text, visit examples. UsageThis command contributes three commands: All three of these commands work on text that is selected. If no text is selected it will use the whole document. The main command: For actual options read the documentation. The second command: The last command:
will (usually*) turn into
*: depends on the file type and your configuration To use the command, first select the text you want to sort, or don't, and it'll
use the entire document. Next go to your command pallete (usually with
Sort-on-saveTo use the sort-on-save feature, you need to mark sections with sort-comments.
Next you need to go to your configuration and turn on Although personally again, I would advise against using sort-on-save, and instead use the cli version of this project. Sort Commentssort-comments are a way for this program to recognize a section to sort. This can help if you have a list that is constantly being updated, and you don’t want to have to keep manually sorting. Example:
Read the actual documentation for more. ConfigurationAll the configuration is under
Decides if the program should always prompt/ask for options when executing the main command. Default:
Decides if the program should try to format sort-comment sections on save. Default:
This is an object which defines the default arguments used in situations. The properties of this object are all strings which follow the cli-like arguments. All the defaults are empty strings.
When you call the main command, if you have
When you call the main command, if you have
When you call the For example, if the value was:
it will turn into
Adding KeybindingsIf you are planning on adding keybindings on the For example:
Acknowledgements
Questions & ContributionThis program might have some learning curve, so if you need any help, submit a GitHub issue, and I'll be glad to help. If you find any bugs or want to contribute also create a GitHub issue. |