1

I use evil via spacemacs. When I use yank, it’s mostly whole line numbers – like y20y. To a lesser extent, this is often true of delete – d10d

Is there anything I can add to my Spacemacs config to toggle on the relative line numbers when I press the first y and to toggle it off if I complete or cancel the yank? And the same for delete? This would make it obvious how many lines I need to yank. It feels like something that should already exist because it is a quite common use case.

1 Answer 1

1

You'll need to install relative-line-numbers for this one

(require 'relative-line-numbers)

(defun yank-with-numbering ()
  (interactive)
  (relative-line-numbers-mode t)
  (call-interactively 'evil-yank)
  (relative-line-numbers-mode -1)
  )
(define-key
  evil-normal-state-local-map ;; or `evil-normal-local-map` if you want it globally
  (kbd "y")
  #'yank-with-numbering)

Maybe (I'm not sure) it's a good exercise that you try and code it yourself for deleting. You can find out the function name for d by doing C-h k d ("help on key 'd'").

Your Answer

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

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