gabesoft / evil-mc

Multiple cursors implementation for evil-mode
MIT License
388 stars 36 forks source link

Make cursor on every line of visual selection #88

Closed walseb closed 5 years ago

walseb commented 5 years ago

In evil/vi if you are in visual mode with a multi-line visual selection and press I or A, you are put into insert mode and when you exit, that insertion will be applied to every line in your visual selection. This patch allows you to instead use multiple cursors to do this which allows for more advanced edits and somehow it seems to perform better than doing it the default way. It seems like this was talked about in #43 and #22.

There is one minor bug I found that I can't bother solving right now however and that is if there is a tab where a cursor is supposed to be it will be put at the end of the tab. You would just need to make it break up the tab into spaces to fix this however.

yuhan0 commented 5 years ago

This looks like a really useful addition :) However there were no keybindings enabled, I assume the intention was to override "I" and "A" in visual state?

(evil-define-key 'visual evil-mc-key-map
  "A" #'evil-mc-make-cursor-in-visual-selection-end
  "I" #'evil-mc-make-cursor-in-visual-selection-beg)
gabesoft commented 5 years ago

I think it's probably better to let the users set these keybindings since some of them will prefer the default behavior for A and I.

yuhan0 commented 5 years ago

Okay, perhaps a snippet or note about this could be added in the Readme?

Evil-mc's default bindings (C-n, C-p, C-t etc.) are pretty intrusive anyways, I didn't think overriding "A" and "I" in visual would be that much further of a stretch.

gabesoft commented 5 years ago

I added the snippet to README in d4acd3376cda2e47913387374927e221ad9eb376