Skip to content

Commit

Permalink
vterm: implement replace
Browse files Browse the repository at this point in the history
Implements evil's "replace" operator ("r") for vterm.
  • Loading branch information
Stebalien authored and condy0919 committed Feb 5, 2024
1 parent 8c84f9b commit 29212d1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions modes/vterm/evil-collection-vterm.el
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ also uses `evil-mode'."

(declare-function vterm-cursor-in-command-buffer-p "vterm")
(declare-function vterm-beginning-of-line "vterm")
(declare-function vterm-insert "vterm")

(evil-define-motion evil-collection-vterm-first-non-blank ()
"Move the cursor to the first non-blank character
Expand Down Expand Up @@ -199,6 +200,14 @@ Save in REGISTER or in the kill-ring with YANK-HANDLER."
(t
(evil-collection-vterm-delete beg line-end type register yank-handler)))))

(evil-define-operator evil-collection-vterm-replace (beg end type register yank-handler)
:motion evil-forward-char
(interactive "<R>")
(let ((replacement (make-string (- end beg) (read-char))))
(evil-collection-vterm-delete beg end type register yank-handler)
(vterm-insert replacement)
(vterm-goto-char (1- end))))

(evil-define-operator evil-collection-vterm-change (beg end type register yank-handler)
(evil-collection-vterm-delete beg end type register yank-handler)
(evil-collection-vterm-insert))
Expand Down Expand Up @@ -280,6 +289,7 @@ But don't allow the cursor to move bellow the last prompt line."
"i" 'evil-collection-vterm-insert
"I" 'evil-collection-vterm-insert-line
"u" 'vterm-undo
"r" 'evil-collection-vterm-replace
"c" 'evil-collection-vterm-change
"C" 'evil-collection-vterm-change-line
"s" 'evil-collection-vterm-substitute
Expand Down

0 comments on commit 29212d1

Please sign in to comment.