Feature Request - multi selection #778
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I know that this might be a big one to get your head around. but its totally worth it.
after i have moved to sublime text 2 for my development. its really hard going back to editors that don't have the multi select feature
it is a killer one and it saves tons of time
if you don't know what it is watch this movie first http://www.youtube.com/watch?v=i2SVJa2EGIw
it takes some time to get to use to the idea that your pointing power was multiplied many-folds. than you really start to invent new ways to work with this
WATCH OUT - if you'll get use to work with multi selection it will be very hard to go back
Awesome!
Agreed. Seems to be a part of all modern editors now.
I think this shouldn't be too hard to create.
Also look at the Match Highllighter demo
Is this also useful for code that's not ridiculously repetitive?
This is cute, but it's not a priority for me.
it is ridiculously productive to any kind of coding. the thing is, it takes a little time to understand the power of this.
we are used to think in a single coding dimension... and the jump to multiple dimensions is to understand there are many many things you can do in different ways
a great example will be if you use search and replace on something..
and you want to replace only most of the matches
traditionally you would go over ALL of them one by one.
with multi select you can just put cursors on all matches (single action), than directly remove the ONLY ones you don't want to change
for example if you want to replace 21 out of 27 matches this will be 7 actions vs 28 actions
(not to mention on each action you have to check yourself if it is a one you want to replace or not)
another example is if you want to add (,) at the end of a block of code at every line
you really have to try it to understand it more
I have been working with it for about a year now with JS HTML C# and python and I still find new ways of using this that amazes me
I think this feature has a lot of hype around it. It was brought by Sublime Text, and it is now implemented by ACE and people seem to love it. I don't use it yet, so I'm not sure about usefulness, but it is cute and I wouldn't mind this being in CodeMirror. Furthermore, I know a lot of people are making (irrational?) decisions about editors based on these kind of innovative features (multiple carrets and selection, block selection...), so if enough people are interested, maybe it's worth a crowd-funding effort? If there was a campaign for that I'd back it.
I think this wouldn't even be that hard to do. But unless it gets funded somehow, or someone else submits a good, clean patch, I don't have time to spend on it.
I think it is a great feature with tons of usefulness and, once you get used to it, very indispensable. It's like using for a while just a computer to write and then going back to use pen and paper, it's AWFUL.
Also I think this feature will bring many more users and costumers to any service using CodeMirror, so I believe it a great feature to spend time, and work on.
I even found this on the CodeMirror Forum at Google Grupos: "...All cursor and selection display is
done through DOM nodes, so you could extend the code to display more
than one." I thought of doing it (a patch or something as marijnh said on a comment, two before this one.) but I'm a student and don't have much time, and also I'm not very experienced on this so even is I manage do it, I think it would be full of bugs and things like that.
mentioned in issue #1032
As
@siefkenjhints in issue #1032, there can be noCtrl-Vselection in vim mode unless there is block selection support in CodeMirror. I guess there can be no block selection without multi selection / multi cursor. To try it out, click onEditin any file on github.com and use theAltkey.Anyone up for crowd-funding the effort to implement this? I use
Ctrl-Vvery often in Vim, and block selection withAlt-Clickcould do really nice in the default keymap.Do these two problems (rectangular selection in vim and sublime text style multi selection) really map to the same implementation? It sounds like rectangular selection is a single selection that happens to not be a single range, whereas sublime text selections are actually multiple selections (if you replace them, all are replaced individually).
In Ace, block selections are composed of multiple single-range selections, with as many new cursors, and I guess Sublime's block selections work similarly.
In Vim, block selections appear to be single selections with a single cursor but multiple ranges. However, if you block select, then hit
S(substitute: delete the selection and go to insert mode), you're going to be inserting text in the first line of the block selection, but as soon as you leave insert mode, all your inserted text is replicated on subsequent lines of the block selection. So I'll argue that Vim's implementation will also work with multiple selections and multiple cursors.EDIT: Maybe I'm not making much sense, but my point is: I think block selection can and should be implemented with multiple single-range selections. No need for single selections that span multiple ranges, since replacing a block selection will always replace each range individually.
I would think any operations on selections would operate on all ranges in all selections, individually. What exactly is the benefit of multiple single range selections over a single multi-range selection?
vim.js's internals are probably (I am too inept in C++ to verify) completely different from Vim's implementation. There wouldn't be much difference to vim.js whether we use multiple single range selections or one multi-range selection.
The only difference between several single-range selections vs a single multi-range selection is that in the first case there are several cursors, implying that any operation is applied to all ranges. The multi-cursor aspect helps operating on all ranges (every selection's cursor inserts / deletes / replaces the same way), and this implementation has the nice effect of giving all at once multiple cloned cursors, multiple selections, and block selection (when those multiple selections happen to form a block).
In Emacs' rectangle-manipulation functions, it is possible to paste one rectangle (represented as a set of equal-length lines on the clipboard-equivalent) into a rectangular selection. That wouldn't naturally play well with a Subline Text / ACE style multi-selection. Not sure how it is in vim.
But, if the vim mode knows it is acting on a rectangle, and it can query the current multi-selection somehow, it would be easy for it to make some API calls that amount to the same effect -- replacing the individual ranges separately. So I guess that yes, having such multi-cursor selections would still be useful.
Vim is also able to paste rectangles anywhere (before inserting the new text, it deletes currently selected text if any, but the pasted section does not care about the shape of the selection it replaces). The behavior I see is, paste the first line of the clipboard as if it was pasted normally, and then paste all the other lines of the clipboard relatively to the first pasted line. For multi-selections that happen to be rectangular, it happens as follows in Vim:
I don't see why having a "multi-cusor-sublime-ace model" would cause trouble implementing rectangular pasting. The Emacs behavior you described sounds to me like:
Does Emacs fit the pasted rectangular text into selected rectangle if their dimensions are different? Maybe that would be a little more tricky.
-----Original Message-----
From: Jan Keromnes notifications@github.com
Date: Mon, 03 Dec 2012 04:28:34
To: marijnh/CodeMirrorCodeMirror@noreply.github.com
Reply-To: marijnh/CodeMirror reply@reply.github.com
Cc: Paulpablokvitca@gmail.com
Subject: Re: [CodeMirror] Feature Request - multi selection (#778)
Vim is also able to paste rectangles anywhere (before inserting the new text, it deletes currently selected text if any, but the pasted section does not care about the shape of the selection it replaces). The behavior I see is, paste the first line of the clipboard as if it was pasted normally, and then paste all the other lines of the clipboard relatively to the first pasted line. For multi-selections that happen to be rectangular, it happens as follows in Vim:
I don't see why having a "multi-cusor-sublime-ace model" would cause trouble implementing rectangular pasting. The Emacs behavior you described sounds to me like:
Does Emacs fit the pasted rectangular text into selected rectangle if their dimensions are different? Maybe that would be a little more tricky.
Reply to this email directly or view it on GitHub:
https://github.com/marijnh/CodeMirror/issues/778#issuecomment-10950928
I just meant that you won't be able to simply use
.replaceSelection(...)to do the rectangle-pasting. Also, there'd be some trickiness handling native paste events. If you have the text to be pasted and you can find out the selection, it is of course possible to implement arbitrary models of replacement.mentioned in merge request !8420
mentioned in issue #1464
mentioned in issue #483
Please implement multiple cursors/selections. I find it extremely useful.
+1 ... where can I go to throw money at this?
mentioned in merge request !8814
+1 I would also highly recommend implementing Sublime Text's Cmd-D shortcut which adds the next occurrence of the selected string to the multi-selection. For example, if my file looks something like
" foo bar foo "
and I select the first "foo",
" foo bar foo "
now, hitting Cmd-D, I can easily select the next "foo"
" foo bar foo "
One of my favorite features in any text editor ever and it shouldn't be too tricky to implement once multi-select is working.
+1 for "next occurrence selection" ... I use that all the time
Also, sublime's
Ctrl+Shift+Lto break up a selection into multiple selection by lines is really useful.This is now implemented in the v4 branch (checkout at http://codemirror.net/4/). I'm not a serious user of any multi-selection-enabled editor myself, so feedback and further feature requests are welcome.
Nicely done. One bit of feedback (initially), esc tends to put the cursor back into single cursor mode. It took me a while to figure out how to go back (mostly because I was using the keyboard to type in multi cursor, so didn't initially think of just clicking else-where).
@remyWell, I did not want to add a binding for Esc to the default set, since that's something people will often bind for their own purposes.keymap/multiselect.jsdefines Alt-Esc for this purpose.Alt-Esc on Windows 7 kind of switches between open windows. You might want to prevent default and stop propagation.
Keybindings are always preventDefaulted when handled. Propagation should not be relevant here.
Ok then, for some other reason, Alt Escape is not working. That is, it is not bringing my number of cursors back to 1.
It's not in the standard bindings, as I mentioned. Try at http://codemirror.net/4/demo/multiselect.html
I tested there only. As soon as I hit Alt Esc, my window changes to other program and the multi selections still remain there.
Ah, then the OS is catching the key before the browser even gets a chance. Scratch alt-esc then. Anyone got another suggestion for a suitable key combination? Or maybe using a default of Esc isn't bad, people who override it can think about providing an alternative mapping themselves.
Can't you have a mapping such that it always is called even if users replace it using extraKeys or keyMappings ?
Just my suggestion:
@remyAgreed. See attached patch.Nice 👯
This looks awesome!
This looks great, nice job!
Ctrl + D is the bookmark shortcut in chrome
CM key bindings only take effect when the editor is focused. Shadowing the bookmark shortcut does not seem like a problem.
@marijnhwe are using multiple selection + searchcursor at https://codebrew.io/ it's looking good for now.@MasseGuillaumeGreat! Thanks for the status report.(Oh, oops, it seems repeatedly rebasing a branch with issue-tagged commits isn't handled very gracefully by github. That's a lot of noise.)
Anyway, this is stable, and certain to be part of 4.0 (most likely to be released next month). Closing.
I'm not sure if anyone said 'thanks' to
@marijnhfor doing this all these years ago.From someone who is benefiting from it now, thanks Marijn.