gabesoft / evil-mc

Multiple cursors implementation for evil-mode
MIT License
383 stars 35 forks source link

mc-make-all-cursors and visual-mode #66

Closed rieje closed 7 years ago

rieje commented 7 years ago

Not sure if I'm doing it incorrectly, but when I visually select lines (for example, this block of code with the my cursor on the last line at the s character and do mc-make-all-cursors, I get the result show in the image--the fake cursor is at the end of the last line.

Instead, I expected the fake cursors to be created at the s character in the same position on the other lines, which is exactly what multi-cursors package does (but for some reason it includes an extra fake cursor after the visually-selected lines).

Is this a bug? Currently I have to narrow the region of interest and then do a grm. This is of course less efficient and also a significant limitation because I can't look at the rest of the text in the buffer. Of course I can do grj instead of narrow region for each line, but that's a lot of typing.

Or is there a way to accomplish this simple task that I don't know about?

Thanks.

gabesoft commented 7 years ago

Did you select the entire block of code? If so, then you'll only get a cursor at the end of that block and any copy of that same block in that file. If you want a cursor at the end of the word setq just run mc-make-all-cursors with the cursor on the setq word (or press ctrl-n assuming the default evil-mc key bindings). You could also select the word solarized and then you'd get a cursor at the end of that word for each instance of it. Hope this helps.

rieje commented 7 years ago

Oh, that makes sense. So you would need to narrow-to-region each time you want to only target a certain portion of the file? multiple-cursors.el has mc/edit-lines which is is what I've described--you select a region of interest in visual mode, run this function, and it will create a cursor on each line at the column your real cursor is on for that region, so there's no need to narrow and widen for quick multi-cursor usage.

If evil-mc doesn't have this feature, what do you think of it? Or is C-n enough in your eyes?

gabesoft commented 7 years ago

Usually, you would want to create a cursor at a particular word, in which case no need to select it, or a part of a word (symbol) in which case you'd need to select that part and run grm or ctrl-n. If you just want to create a cursor for several lines regardless of text you can use grk or grj which can be prefixed by a number. For example, to create a fake cursor at the next 3 lines below the real cursor use 3grk

rieje commented 7 years ago

I actually don't use (relative) line numbers even though I use evil. I'm using evil's evil-avy-goto-line (similar to easymotion which I see you use), which is normal avy-goto-line but suports vim motions. So for example, to delete a line, I do dL<char_matching_line> (L is bound to the function) to delete lines from current position to specified line. But it seems I cannot get this to work with evil-mc--for example I've tried grL and it doesn't work.

Is this something that needs to be explicitly supported by evil-mc for it to work? I'd rather not use (relative) line numbers just for evil-mc.

gabesoft commented 7 years ago

Oh, I see. Yea there would be some work required to make it work with avy-goto-line

gabesoft commented 7 years ago

I believe this issue is a duplicate of #22. See that issue for some code snippets that might work.