1

I want to emulate this vim remap in evil-emacs (doom emacs).

nnoremap <leader>mpp ciw<C-r>0

I want to change the word on point (I don't mind word or Word, just want the evil-change with evil-inner-word syntax). If possible I want it defined on an interactive function to remap it to leader mpp.

I want a remap that substitutes current word on point with yank/clipboard content.

Thanks in advance.

1 Answer 1

0

I think this works as you want. Non-evil mode that I originally wrote for reference, as I'm not a day-to-day evil-mode user.

(defun replace-word-at-point ()
  (interactive)
  (let ((bounds (bounds-of-thing-at-point 'word)))
    (if bounds
      (progn (delete-and-extract-region (car-safe bounds) (cdr-safe bounds))
             (yank))
      (message "No word at point"))))

(defun replace-evil-word-at-point ()
  "Select the word at point, remove it, and yank the most recent killed text. "
  (interactive)
  (let ((bounds (evil-inner-word)))
    (if bounds
      (progn (delete-and-extract-region (pop bounds) (pop bounds))
             (yank))
      (message "No word at point"))))

For instance (bold = character at point in each example, just take my word that the space is a bold space in the last one):

Original Plain emacs Evil version
this is my test word this is my test Hello! this is my test Hello!
this is my test word this is my test Hello! this is my test Hello!
this is my test word this is my Hello! word this is my testHello!word
1
  • This worked perfectly, thank you!
    – Mr. Weckx
    Commented Jul 13, 2021 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.