krasa / StringManipulation

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

Feature request: tail trim #211

Closed gberche-orange closed 1 year ago

gberche-orange commented 1 year ago

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

Some terminal based interactive tools (using libraries such as curses, e.g. k9s https://github.com/derailed/k9s/issues/1106 ) add trailing spaces to each lines.

The current trim feature seems to also remove prefix spaces, which breaks indentation-sensitive formats such as yaml. I did not yet find a way to configure the trim function to preserve leading spaces.

Describe the solution you'd like

Given the following file with tailing spaces (end of lines is artifically showed as $ when you scroll right)

kind: Pod                                                                                                                                                                                                          $
metadata:                                                                                                                                                                                                          $
  annotations:                                                                                                                                                                                                     $
    openshift.io/scc: anyuid                                                                                                                                                                                       $
  creationTimestamp: "2023-07-26T20:11:06Z"                                                                                                                                                                        $
  generateName: kuttl-01-static-medium-pg-manual-6bh-                                                                                                                                                              $
  labels:                                                                                                                                                                                                          $
    controller-uid: 742f8f22-49b6-4371-805b-30168e1014c0                                                                                                                                                           $
    job-name: kuttl-01-static-medium-pg-manual-6bh                                                                                                                                                                 $
    kapp.k14s.io/app: "1690214073064745050"                                                                                                                                                                        $
    kapp.k14s.io/association: v1.3ebfbbdcee86e79fd3a0323ef3706119                                                                                                                                                  $
  name: kuttl-01-static-medium-pg-manual-6bh-mc4wn                                                                                                                                                                 $
  namespace: 75-crossplane-tests                                                                                                                                                                                   $
  ownerReferences:                                                                                                                                                                                                 $
  - apiVersion: batch/v1                                                                                                                                                                                           $
    blockOwnerDeletion: true                                                                                                                                                                                       $
    controller: true                                                                                                                                                                                               $

When executing tail trim Then only trailing spaces are removed, resulting in (end of lines is artifically showed as $)

kind: Pod$
metadata:$
  annotations:$
    openshift.io/scc: anyuid$
  creationTimestamp: "2023-07-26T20:11:06Z"$
  generateName: kuttl-01-static-medium-pg-manual-6bh-$
  labels:$
    controller-uid: 742f8f22-49b6-4371-805b-30168e1014c0$
    job-name: kuttl-01-static-medium-pg-manual-6bh$
    kapp.k14s.io/app: "1690214073064745050"$
    kapp.k14s.io/association: v1.3ebfbbdcee86e79fd3a0323ef3706119$
  name: kuttl-01-static-medium-pg-manual-6bh-mc4wn$
  namespace: 75-crossplane-tests$
  ownerReferences:$
  - apiVersion: batch/v1$
    blockOwnerDeletion: true$
    controller: true$

Describe alternatives you've considered

As a workaround in intellij, I'm using multi cursor, go to end of line, select backward to last word, exclude last char and delete (5+ keystrokes)

Additional context Add any other context or screenshots about the feature request here.

gberche-orange commented 1 year ago

Awesome, thanks a lot @krasa for such prompt feature contribution !