gabesoft / evil-mc

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

Allow running arbitrary commands for all cursors #15

Closed gabesoft closed 8 years ago

gabesoft commented 8 years ago

In magnars' multiple-cursors package one can do that like this:

(mc/for-each-cursor-ordered (mc/execute-command-for-fake-cursor 'insert-magic-number cursor))

(defun insert-magic-number () (interactive) (insert (number-to-string 42))

Or something like this:

(defun mc/sort-regions () (interactive) (unless (use-region-p) (mc/execute-command-for-all-cursors 'mark-sexp)) (setq mc--strings-to-replace (sort (mc--ordered-region-strings) 'string<)) (mc--replace-region-strings))