17

Today I noticed that Stack Snippets support multiple text cursors. Holding Ctrl and clicking into a new line places a secondary cursor (at least in FF 53.0):

Screenshot:

Multiple Cursors

While this might be a hidden niche feature for e.g. formatting or manual loop unrolling, I don't think it is intended behavior - or is it?

I couldn't find any discussion regarding this on meta, searching for "stack snippet" and "cursor" yields nothing.

14
  • 2
    Firefox has a long and checkered history of caret bugs. Do try this in another browser to compare. May 1, 2017 at 7:22
  • 2
    @HansPassant I can at least confirm it is in Chrome v58.0.3029.81.
    – Daedalus
    May 1, 2017 at 7:59
  • 28
    [feature-request] implement this everywhere.
    – Kaiido
    May 1, 2017 at 9:19
  • 1
    More seriously, if you believe it is a bug, then I think it should be raised to CodeMirror lib, which doesn't seem to expose an option to force a single cursor. Btw @HansPassant, I don't think there remains anything from native browser's implementations in there.
    – Kaiido
    May 1, 2017 at 9:28
  • 16
    Sounds like a deliberate behaviour to me. Sublime Text has exactly this feature, and probably some other editors do too. (And it's very useful!)
    – Mark Amery
    May 1, 2017 at 9:40
  • 1
    @MarkAmery You might be right. However, I found it irritating when selecting separate words by holding [Ctrl] and then cutting them via [Ctrl] + [x] and having to deal with multiple unexpected "left-over" cursors afterwards.
    – le_m
    May 1, 2017 at 11:30
  • 5
    @Kaiido +1 because I want this in everything I use. OpenOffice, Visual Studio, Bash, my social life, everything!
    – Nic
    May 1, 2017 at 16:27
  • 1
    @QPaysTaxes This extension gives this for Visual Studio (but uses Alt instead of Ctrl). I use it all the time! marketplace.visualstudio.com/… May 1, 2017 at 18:50
  • @mrsundquist Ooh, that's nice. Visual studio has... something, but it only allows a bunch of cursors in the same column, doesn't let you move it with the arrow keys, etc. etc. (it's bad.) This is gonna be great!
    – Nic
    May 1, 2017 at 18:52
  • But does it work? I mean, if you type a letter, does it appear on all four positions? If not, then it's a bug (which can be resolved either way). If it is, then it's a feature, just like in Sublime Text =)
    – justhalf
    May 2, 2017 at 2:42
  • 3
    Why would this not be intended behaviour? You can click anywhere to dismiss multiple cursors, so if you activate this unintentionally, it’s not hard to deal with….
    – Ry- Mod
    May 2, 2017 at 2:59
  • @justhalf looking at the screenshot it seems to work.
    – Veve
    May 2, 2017 at 7:56
  • 'We have discovered the hidden feature' 'Cursors!'
    – user5940189
    May 2, 2017 at 9:43
  • 2
    Looks like a feature, smells like a feature, so I guess it is a feature? Even if it was a bug, I would say "it's not a bug, it's a feature".
    – g00glen00b
    May 2, 2017 at 10:01

1 Answer 1

6

As @Kaiido and @g00glen00b pointed out in the comments (Ref 1, Ref 2), this is a feature of CodeMirror.

And it is a great feature! It took me by surprise at first, as I didn't expect being gifted additional text cursors after performing a multi-selection Ctrl+X. That's why I posted this question here on meta, in disbelief. It seemed too good to be a feature, it couldn't be, I had never heard or even thought of it. But since then I have come to love the ability to perform all kinds of parallel text manipulations in a single step, by using multiple text cursors. I started answering questions just so I could watch these little bustling carets spouting text here and there. It feels incredibly productive. And it is!

Hopefully, this question will allow more people to discover this handy little feature. I will tag it as .


Edit: Only moderators can tag it as , so we will have to wait a little bit.

You must log in to answer this question.

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