richrd/suplemon

[Wishlist] in multi cursor mode execute find for each cursor

Closed this issue · 3 comments

Or provide a second function like find which works for multi cursor.
That would actually be more useful because then find can still be used to create multiple cursors.

e.g. if we have following code:

        # backspace is tricky:
        # ctrl+backspace returns keycode 8
        # backspace returns keycode 127/KEY_BACKSPACE
        _fmt("backspace"):                         127,
        _fmt("backspace"):                         "KEY_BACKSPACE",
        _fmt("backspace", "alt"):                  "m-KEY_BACKSPACE",
        _fmt("backspace", "alt"):                  "m-c127",
        _fmt("backspace", "alt", "ctrl"):          "m-c8",
        _fmt("backspace", "ctrl"):                 8,
        # additional modifyOtherKeys variants
        _fmt("backspace"):                         "c127",
        _fmt("backspace", "alt", "ctrl"):          "m-c-c8",
        _fmt("backspace", "alt", "ctrl", "shift"): "m-c-s-c8",
        _fmt("backspace", "alt", "shift"):         "m-s-c127",
        _fmt("backspace", "ctrl"):                 "c8",
        _fmt("backspace", "ctrl", "shift"):        "c-s-c8",
        _fmt("backspace", "shift"):                "s-c127",

Target: convert it into a format like (last line as example) add("shift", "backspace", "s-c127")
That is, move "backspace" to be the second last parameter and replace "_fmt" by "add" and "):" by "," and ",$" by ")".

  • "multi-cursorize" all _fmt lines
  • Home, remove "_fmt", write "add"
  • position the cursors on the start of "backspace, " and delete
  • this does not work:
    • c-f to search for ":"
    • delete "):", write ', "backspace",'
  • End, remove ",", write ")"

Edit:
Just recognized I don't need to move the parameter at all, but the same issue exists for converting "):" to "," and it would generally be a useful feature to have.

Here's how I would proceed with your use case (with the suplemon limitations):

  • "multi-cursorize" all _fmt lines
  • Home, remove "_fmt", write "add"
  • position the cursors on the start of "backspace, " and press enter
  • move to end of "backspace" and press enter again
  • move the cursors one line up (now each cursor is on a line that only contains "backspace")
  • cut those lines
  • now press backspace to "unsplit" the original lines (join each line back to a single line)
  • press ESC and find "):" and select all
  • type "," and paste to insert all the "backspace" lines thaw were cut to the end of the function call
  • press home, and move to end of first ", " and press backspace twice to remove comma and space from start of call

Basically the idea here is, that since we can't make selections within lines, we move what we want to its own line. The it can be cut/copied and after that the lines can be joined back to what they were before.

If we had real selections this would be so much easier... 🤔

press ESC and find "):" and select all

Yes one can return to single cursor mode and create a new set of multi cursors.
Personally, I'd prefer a find like feature (which doesn't create new cursors) which works for multiple cursors though.

Afaik sublime doesn't do this either so closing for now. It might be done in the future.