krasa / StringManipulation

IntelliJ plugin - https://plugins.jetbrains.com/plugin/2162
Apache License 2.0
694 stars 81 forks source link

[option] Ignore Leading Characters (to sort commented lines alongside uncommented lines) #213

Closed randolf-scholz closed 1 year ago

randolf-scholz commented 1 year ago

Is your feature request related to a problem? Please describe.

Sometimes I want to sort lines in configuration-files. Often, certain configuration options are commented out, but when sorting I'd like to keep them in order.

Examples:

Sorting dependencies in a pyproject.toml file ```toml [tool.poetry.group.jupyter.dependencies] ipydex = ">=0.16.0" ipympl = ">=0.9.3" ipython-autotime = ">=0.3.1" ipywidgets = ">=8.1.0" jupyter-client = ">=8.0.0" jupyter-core = ">=5.3.0" jupyter-packaging = ">=0.12.3" jupyter-resource-usage = ">=1.0.0" jupyterlab = ">=3.6.5" jupyterlab-code-formatter = ">=1.6.1" # jupyterlab-drawio = ">=0.9.0" jupyterlab-execute-time = ">=3.0.0" jupyterlab-git = ">=0.41.0" jupyterlab-lsp = ">=4.2.0" jupyterlab-mathjax3 = ">=4.3.0" jupyterlab-spellchecker = ">=0.8.3" # jupyterlab-spreadsheet-editor = ">=0.6.1" jupyterlab-templates = ">= 0.4.0" jupyterlab-pyflyby = ">=5.0.0" # jupyterlab-skip-traceback = ">=5.0.0" # jupyterlab-tensorboard-pro = ">=0.7.0" jupyterlab_widgets = ">=1.0.2" jupytext = ">=1.15.0" nbconvert = ">=7.7.3" nbdime = ">=3.2.1" nbstripout = ">=0.6.1" notebook = ">=6.5.4" python-lsp-server = ">=1.7.4" rise = ">=5.7.1" # voila = ">=0.4.0" ```
Sorting disabled error codes in an `.ini`-file ```ini disable= "C0103", # invalid-name ; "C0144", # non-ascii-name "C0204", # bad-mcs-classmethod-argument "C0415", # import-outside-toplevel "E0611", # no-name-in-module "E1101", # no-member # FIXME: too many false positives "E1121", # too-many-function-args # too many false positives "E1123", # unexpected-keyword-arg # too many false positives "E1130", # invalid-unary-operand-type "R0801", # similar lines "R0902", # too-many-instance-attributes "R0903", # too-few-public-methods "R0911", # too-many-return-statements "R0913", # too-many-arguments "R0914", # too-many-locals "R0915", # too-many-statements ; "W0221", # arguments-differ ; "W0511", # (fixme) (todos) "W1113", # keyword-arg-before-vararg "W2301", # unnecessary-ellipsis ```

Describe the solution you'd like

Currently, there is only an option to ignore leading whitespace characters. This can be generalized:

For example, for the pyproject.toml-file one could specify #\s* or \s*#\s* and for the .ini-file one could specify ;\s* or \s*;\s*.

krasa commented 1 year ago

You can update.

Ignore Leading Spaces is used before and after Ignore Leading Characters.