Change :mc to take delimited pattern
This used to take a regexp after a space: ':mc REGEXP'. It now is delimited, like :g or :s, e.g. :mc/REGEXP/FLAGS :mc/[a-z] :mc/abc/g
This commit is contained in:
parent
075bc1797b
commit
f763bf2fd0
1 changed files with 19 additions and 7 deletions
|
@ -45,12 +45,14 @@ pauses cursors."
|
|||
(evil-mc-make-cursor-here))))
|
||||
|
||||
;;;###autoload (autoload '+multiple-cursors:evil-mc "editor/multiple-cursors/autoload/evil-mc" nil t)
|
||||
(evil-define-command +multiple-cursors:evil-mc (beg end type pattern &optional bang)
|
||||
"Create mc cursors at each match of PATTERN within BEG and END, and leave the
|
||||
cursor at the final match. If BANG, then treat PATTERN as literal."
|
||||
(evil-define-command +multiple-cursors:evil-mc (beg end type pattern &optional flags bang)
|
||||
"Create mc cursors at each match of PATTERN within BEG and END.
|
||||
|
||||
This leaves the cursor at the final match. If BANG, then treat PATTERN as
|
||||
literal. PATTERN is a delimited regexp (the same that :g or :s uses)."
|
||||
:move-point nil
|
||||
:evil-mc t
|
||||
(interactive "<R><//g><!>")
|
||||
(interactive "<R><//!><!>")
|
||||
(unless (and (stringp pattern)
|
||||
(not (string-empty-p pattern)))
|
||||
(user-error "A regexp pattern is required"))
|
||||
|
@ -59,9 +61,19 @@ cursor at the final match. If BANG, then treat PATTERN as literal."
|
|||
(cons (evil-ex-make-search-pattern
|
||||
(if bang (regexp-quote pattern) pattern))
|
||||
(list beg end type)))
|
||||
(save-excursion
|
||||
(evil-with-restriction beg end
|
||||
(evil-mc-make-cursors-for-all)))
|
||||
(evil-with-restriction beg end
|
||||
(let ((point (point)))
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
(while (eq (evil-ex-find-next (evil-mc-get-pattern) 'forward t) t)
|
||||
(goto-char (1- (point)))
|
||||
(when (/= point (point))
|
||||
(evil-mc-run-cursors-before)
|
||||
(evil-mc-make-cursor-at-pos (point)))
|
||||
(goto-char
|
||||
(if (memq ?g flags)
|
||||
(line-beginning-position 2)
|
||||
(1+ (point))))))))
|
||||
(evil-exit-visual-state)
|
||||
(evil-mc-goto-cursor
|
||||
(if (= (evil-visual-direction) 1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue