Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple cursors ? #101

Closed
syl20bnr opened this issue Nov 9, 2014 · 32 comments
Closed

Multiple cursors ? #101

syl20bnr opened this issue Nov 9, 2014 · 32 comments

Comments

@syl20bnr
Copy link
Owner

syl20bnr commented Nov 9, 2014

I wish we could integrate consistently multiple cursors from @magnars.

I don't need it so often with the tools available in Spacemacs and the macros but sometimes it would be extremely useful and no doubt that if we could have it in our tool belt we could find a lot of cool use cases for it.

The tricky part is to make it play well with evil. There is a long opened issue on this topic here.

Are there any ST users here who can relate about their experience with multiple cursors ?

@trishume
Copy link
Contributor

trishume commented Nov 9, 2014

This was one of my favourite features of Sublime Text and one of the reasons I kept coming back to it.
It's so much nicer than having to use Visual Block Mode (which is also broken #98).

Sublime Text's vim emulation plugin was built from the start to be compatible with it, but one can hope that Evil might be able to work with it someday.

@syl20bnr
Copy link
Owner Author

syl20bnr commented Nov 9, 2014

Maybe a valid approach would be to develop from the ground up an evil-multiple-cursors mode.

@syl20bnr
Copy link
Owner Author

Another point of view similar to trishume: http://www.reddit.com/r/vim/comments/2mqjks/the_one_thing_i_miss_from_sublime_text_atom/

@syl20bnr
Copy link
Owner Author

@trishume We could try to add multiple-cursors to spacemacs layer and automatically switch to emacs state when triggering it. From here we will be able to experiment. What do you think ?

@trishume
Copy link
Contributor

That would be an option that might help some users. It certainly wouldn't help me though, since Spacemacs is so great I know a grand total of 1 normal emacs command: M-x.

@syl20bnr
Copy link
Owner Author

@danielwuz
Copy link
Contributor

To rename symbols, I use iedit, it works exactly like the gif demo in the link you posted, and it works well with text-object. Maybe we can consider including it into spacemacs for renaming task before multiple-cursor can work along with evil

@syl20bnr
Copy link
Owner Author

What are the differences between iedit and auto-highlight-symbol (<SPC> s e) ?

@CestDiego
Copy link
Contributor

It doesn't have scope (line,function, object, whatever..) It just checks for coincidences in the current buffer... But also Iedit lets you edit multiple ocurrences of a region (and even a rectangle region) So that spacemacs/init spacemacs/config are two different symbols, but if you select in a region "spacemacs" then both will be edited. (this cannot be achieved with ahs).

For scoping though, you can specify how many lines above or below of the current selection you want your customizations to take effect

@danielwuz
Copy link
Contributor

I've made a short video to demonstrate how iedit work for renaming variables as well as specific pattern in a function. You may download it here. https://www.dropbox.com/s/nxdv8cy2xh8mhjf/2014-11-30_1745.swf?dl=0

In this video, I was renaming variable i to more meaningful name layer and j to offset in a function. As you may notice that the variable i out of function scope doesn't get effected. In addition, I can select a region, n - 1 in my demo, and change all occurrence in function. What's more, when I do undo, all changes will be un-done.

This video is in swf format, you should be able to open it with any browser. Made it in a hurry, don't know how to convert to gif yet.

@danielwuz
Copy link
Contributor

There're definitely overlapping of function between iedit and ahs. What I like iedit over ahs is that it's easy to change scoping( with C-0) and it shows an overlay of all places that's gonna edit. Besides, as @CestDiego mentioned, you can exclude occurrence that you don't wan to update.

iedit also has rectangle mode, but that is overlapped with visual-block in evil

@CestDiego
Copy link
Contributor

I must be using iedit wrong because I didn't know about the scoping feature! D: ok, removing ahs for me now.... The only thing that affects me is that well symbols are not highlighted :P, and that sometimes iedit screws up the undo tree :(

@syl20bnr
Copy link
Owner Author

Thank you for the video this is super useful.

You forget to mention the navigation features of ahs with underline of the definition of a variable (when available for the current major mode). Can you do this with iedit ?

For me the only useful addition of iedit over ahs is the possibility to edit a selection which is very handy. So what I propose is that <SPC> s e when it operates on a selection dispatch the work to iedit.

I will experiment with this a little bit to see if I can make all these things to work together consistently.

@CestDiego
Copy link
Contributor

^ that was something that I was trying to do but my elisp knowledge kinda limit me :( If you do that .. that would be awesum

@syl20bnr
Copy link
Owner Author

Another approach is to keep ahs for auto-highlight and navigation and switch to iedit for edition. I will test this possibility too.

@danielwuz
Copy link
Contributor

In terms of navigating between variable occurrences, short answer is yes. there's iedit-next-occurrence and iedit-goto-last-occurrence which does what you expect, but I don't have a binding for them as iedit works pretty well with ahs, I simply use ahs for navigation.

In my opinion, iedit is one of the small things that do one thing and do it well, i.e. editing multiple occurrences. I like the way that it puts overlay to editing regions when entering iedit-mode. This is very similar to the idea of state in vim. Any change you made beyond those regions will not reflect to other places. Thanks to that, I rarely screwed up my editing, and this is why I prefer iedit over multiple-cursor. multiple-cursor, as far as I'm concerned, only works fine when there's a certain pattern in your text structure, I found it's hard to use because when I move my cursor, I have to be very careful so as not to screw up my cursors. I prefer using macro in that case.

I think couples reasons that iedit is less popular is #1 it's not very well documented, #2 not under active development, and #3 less functionality comparing to multiple-cursor.

@syl20bnr
Copy link
Owner Author

syl20bnr commented Dec 1, 2014

multiple-cursors has no function to act like iedit ? Seems on the gif that it has the same functionality with overlays. The fact that iedit can replace selections make it a good alternative to multiple-cursors, a lot better than ahs.

@danielwuz
Copy link
Contributor

I mean, they have pretty much the same functionality, except mc can move cursors around and still keep editing =). I didn't know that mc also uses overlay.

@syl20bnr
Copy link
Owner Author

syl20bnr commented Dec 1, 2014

I added an issue for this (see above).

@CestDiego
Copy link
Contributor

Will this actually work now with the spacemacs/ground-control? :)

@shaief
Copy link

shaief commented Apr 14, 2015

any news regarding this issue? was someone able to make multiple-cursors play nice with spacemacs?
Thanks!

@trishume
Copy link
Contributor

A layer for this could totally happen now for use by holy-mode people.

@syl20bnr
Copy link
Owner Author

I will do some work on this, I might be able to do something interesting even for vim users.

@shaief
Copy link

shaief commented Jun 14, 2015

Hi @syl20bnr, did you manage to make EVIL and multiple-cursors play nice together?

@syl20bnr
Copy link
Owner Author

Not for now, I tried a long time ago and it was not really usable. One known trick is to only use it in insert state but it is pretty limited. Or you learn some basic emacs key bindings and you switch to emacs state while in multiple cursor.

@shaief
Copy link

shaief commented Jun 15, 2015

Thanks for answering!

@jimmythekid
Copy link

has there been any more work around a multi-cursor mode for evil users in spacemacs?

@snario
Copy link

snario commented Aug 3, 2015

+1 this is a deal breaker for many people

@rugginoso
Copy link

+1

@Kethku
Copy link
Contributor

Kethku commented Sep 1, 2015

Progress is being made here: #2669

@rjhilgefort
Copy link

👍

@TheBB
Copy link
Contributor

TheBB commented Sep 12, 2015

I'm closing this in favour of #2669.

@TheBB TheBB closed this as completed Sep 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests