Requirements Auto Sort is a Visual Studio Code extension that automatically sorts the contents of requirements.txt files. The extension can be triggered either by saving the file or by manually running a command from the Command Palette.
Features
Automatic Sorting on Save: Sorts your requirements.txt file alphabetically every time you save it.
Comment Retention: Keeps comments associated with the relevant requirement and places them above the requirement.
Manual Sorting Command: Use the Sort Requirements command from the Command Palette to sort manually.
Installation
From the VS Code Marketplace
Open Visual Studio Code.
Navigate to the Extensions view by clicking on the Extensions icon in the Activity Bar or pressing Ctrl+Shift+X (Cmd+Shift+X on macOS).
Press F5 to launch the extension in a new Extension Development Host window.
Usage
Automatic Sorting on Save
Simply save your requirements.txt file, and the extension will automatically sort its contents alphabetically, preserving associated comments.
Manual Sorting Command
Open the requirements.txt file you wish to sort.
Open the Command Palette by pressing Ctrl+Shift+P (Cmd+Shift+P on macOS).
Type Sort Requirements and select the Sort Requirements command.
The file will be sorted, and a success notification will appear.
Configuration Settings
Still In Development
Examples
Example Before Sorting
flask==1.1.1
# Comment about pandas
pandas==1.2.0
# Comment about numpy
numpy==1.19.3
Example After Sorting
# Comment about numpy
numpy==1.19.3
# Comment about pandas
pandas==1.2.0
flask==1.1.1
GIF examples coming soon
Requirements
This extension requires:
Visual Studio Code: Version 1.96.0 or higher.
A valid requirements.txt file in your workspace.
Note: The file must be named exactly "requirements.txt". This extension was developed and tested on VS Code version 1.96.2. Compatibility with earlier versions has not been verified.
Release Notes
Please refer to the CHANGELOG file for detailed release notes.
Version 0.1.0
Initial release of Requirements Auto Sort.
Version 0.2.0
Release Date: 2024-12-31
Upcoming Features
Future releases will introduce customizable sorting options, enabling users to select ascending or descending order and tailor how comments, package pairs, duplicates, and other elements are managed.