2

Could we have support for multi-cursor editing (a.k.a "multi-caret") in the post editor? Often I find myself fixing indentations and would love to just have multiple simultaneous cursors e.g to remove unnecessary spaces on multiple lines. This could also be used for prefixing multiple variable names or adding modifiers in certain languages (adding private for example to multiple variables).

Most IDEs have the possibility to place multiple cursors either clicking while holding down a certain key (ALT + click in VS Code for example) or by moving up or down with another key combination. Mostly, the cursors are removed again by hitting the ESC key.
Having this possibility in the editor would be awesome and could help in multiple cases as mentioned above.

12
  • 1
    Not supported right now. Not sure it ever will. There are userscripts that add mass indent/unindent but I'm not aware of any that allow for multi-cursor.
    – VLAZ
    Jun 27, 2022 at 9:06
  • 12
    Nope, I usually just copy it into a proper text editor or IDE.
    – Cerbrus
    Jun 27, 2022 at 9:09
  • 2
    I’ve long since given up hope of being provided with adequate tools to clean up the mass of awfully formatted posts on SO.
    – user438383
    Jun 27, 2022 at 10:43
  • Re "a multiline cursor to remove unnecessary spaces on multiple lines": Presuming leading spaces, I have a public utility for that: "Remove common leading space" (though I don' use it on Stack Exchange, only for automating transforming comments/annotation in an internal format to YouTube/LBRY comments in an acceptable form ("Convert to Markdown code fencing" removes (fixed) four spaces)). The copy/paste back and forth, changing focus, etc. is tedious, so I make common operations a one-step process with a macro keyboard (without any modifier keys). Jun 27, 2022 at 11:30
  • Though similar JavaScript-based solutions and workarounds must exist. Jun 27, 2022 at 11:31
  • 4
    I've closed this because "edit multiple lines in posts" is substantially inadequate to describe whatever it is that you're really asking for. This seems to be that you're asking for a combination of multi-line indent/unindent, a global search and replace capability, and/or a search and replace capability which is limited to an area which you've selected. Each of those should be a separate feature-request, rather than grouping them all in a single post. Even then, I'm not really sure I've understood what you're asking for. Please edit to clarify and limit it to a single feature.
    – Makyen Mod
    Jun 27, 2022 at 16:20
  • I've edited and added an extra paragraph to explain. Indent/unindent would be only one of the possibility with this feature. It's more about having multiple cursor places at the same time.
    – dumazy
    Jun 27, 2022 at 17:14
  • 1
    You would get more "Support" if your Title was a bit "clearer"... "edit multiple lines in posts" = unclear, "Multiline editing posts" = also unclear, I thought you meant Multines in Comments (with Linebreaks)... => Maybe a bit clearer...: "Multiline Editing (indent/unindent) in Code Blocks"...
    – chivracq
    Jun 27, 2022 at 23:16
  • Stack-snippets's editor has this feature already: Multiple text cursors in stack snippets? – Would be great to have the same for the whole post editor.
    – Kaiido
    Jun 28, 2022 at 2:30
  • It isn't multi-cursor. It is block mode or block/rectangular selection if it isn't an actual mode (AKA column selection AKA Column Mode (UltraEdit) AKA "visual mode" (Vim) AKA "Column Selection mode" (Visual Studio Code)). Jun 28, 2022 at 11:42
  • 1
    @PeterMortensen I made the edit introducing this "multi-cursor" term and I still believe that it's what OP is after. The Alt+Click sequence they talked about in VS code is for "multi-cursor", as the link I introduced in the question calls it. In UltraEdit it's called "multi-caret". Vim doesn't have this feature without a plugin.
    – Kaiido
    Jun 28, 2022 at 12:58
  • 1
    As @Kaiido mentions, the 'multi-caret' feature is what I would like to see
    – dumazy
    Jun 28, 2022 at 19:08

1 Answer 1

9

This isn't an answer to your feature request but a workaround for the problem:

[I] would love to just have a multiline cursor to remove unnecessary spaces on multiple lines.

If it's just for fixing indentation that you want this, I often just select the block of text, and pressing the "Code Sample" ({}) button in the toolbar until I can then add code fences around the unindented text:

This can also be done without a mouse or keyboard (e.g. on a mobile device).

Would that suffice as a workaround?

4
  • 3
    It's not an answer to the feature request but it's definitely a workaround I will use. Thank you so much!
    – dumazy
    Jun 27, 2022 at 11:04
  • 1
    This workaround only works if the indentation is divisible by 4. If it is not (e.g. because there is extra two spaces) then it fails and still requires manual intervention.
    – VLAZ
    Jun 27, 2022 at 13:18
  • Note that there's also a keyboard shortcut for this as well: Ctrl+K.
    – zcoop98
    Jun 27, 2022 at 16:45
  • You can expect this to work for maybe 6-8 more months, then they'll replace that editor with the Stacks editor entirely which instead of indenting makes code fences. (Am I jaded... or realistic?)
    – Laurel
    Jun 28, 2022 at 4:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .