gabesoft / evil-mc

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

Is there ex command? #108

Closed triplc closed 4 years ago

triplc commented 4 years ago

Hi,

It is an ex command --mc-- to create cursors using ex. Example:

:-10,+10mc evil-mc.*match

(evil-define-command evil-mc-ex-match (&optional beg end regexp)
  "Ex command for invoking evil-mc with a regular expression."
  (interactive "<r><a>")
  (if regexp
    (let ((b (if (region-active-p) beg (point-min)))
          (e (if (region-active-p) end (point-max)))
          (r (evil-ex-make-pattern regexp evil-ex-search-case nil)))
      (set-mark (point)) ;; remember current position, so, C-u C-SPC would go back to this pos
      (goto-char b)
      (evil-mc-run-cursors-before)
      (while (and (<= (point) e)
                  (eq (evil-ex-find-next r 'forward t) t))
        (evil-mc-make-cursor-at-pos (match-beginning 0)))
      (evil-mc-find-and-goto-cursor 'evil-mc-find-first-cursor nil)
      (add-to-history 'regexp-search-ring regexp regexp-search-ring-max)
      (add-to-history 'evil-ex-search-history regexp)
      (setq evil-ex-search-pattern r)
      (setq evil-ex-search-direction 'forward))))
(evil-ex-define-cmd "mc" 'evil-mc-ex-match)
gabesoft commented 4 years ago

There isn’t but feel free to add it