Lines Sorter Plus is a plugin for the IntelliJ Platform (IDEA, WebStorm, PhpStorm, etc.) which alphabetically sorts texts and JSON objects. This plugin is based on Sylvain Francois' Lines Sorter and emerged from this discussion.
Just click on "Edit" and select "Lines Sorter Plus" after you installed this plugin from the JetBrains Marketplace.
You can also activate "Lines Sorter Plus" by pressing Alt + Shift + L
:
Info: The plugin differentiates between "selection mode" and "file mode". When you select code with your cursor, then the plugin will format the selected lines of code in "selection mode". When you have no active selection, then the plugin will sort your whole file in "file mode". It supports sorting plaintext and JSON structures (in *.json files).
- Amazon Corretto 11 (OpenJDK)
- IntelliJ IDEA 2021.3.1 (Community Edition) or later
- Activated DevKit Plugin
Click "Open Module Settings (F4)" to see your attached SDKs. You need to use Java SDK 11 when targeting IntelliJ IDEA 2020.3 or later (source).
When using a non-fitting JDK, you will see:
Error:java: release version 5 not supported
When using a newer JDK (e.g. Oracle OpenJDK 17.0.1), you will run into:
com.intellij.ide.plugins.StartupAbortedException: UI initialization failed
When you don't have an "IntelliJ Platform Plugin SDK" assigned to this project, the code will fail to import from com.intellij or org.jetbrains:
java: package com.intellij.openapi.actionSystem does not exist
This can be fixed by navigating to "File" - "Project Structure". You should see an "SDK" section where you have to select an "IntelliJ IDEA Community Edition" SDK. If you don't have any, click on "Add SDK" and select "IntelliJ Platform Plugin SDK" (tested with IntelliJ IDEA 2023.2.1, Community Edition):
Build and tested with:
- IntelliJ IDEA 2021.3.1 (Community Edition)
Created with the following template:
- File ➝ New ➝ Project ➝ IntelliJ Platform Plugin (without Gradle)
When running the plugin, a Sandbox IDE will be started which has the plugin installed. Here is how you can view the logs (with "info" log level) on your system.
With Windows PowerShell:
Get-Content -Path "C:\Users\bn\AppData\Local\JetBrains\IdeaIC2021.3\plugins-sandbox\system\log\idea.log" -Wait
Code formatting is done with Prettier which gets installed through npm:
npm install
npm run fix
Staged files in Git get automatically formatted with pretty-quick.
- Select plugin in the "Project" window
- Do a right-click and select "Prepare Plugin Module For Deployment"
- Publish .jar file on JetBrains Marketplace through Upload Update