I'm trying to reverse some words, and I have it set up where I can visually select them and hit
,rw to reverse them.
How do I set it up so ,rw also works with a motion. E.g.
,rw3w to reverse 3 words?
(defun reverse-words (beg end) "Reverse the order of words in region." (interactive "*r") (apply 'insert (reverse (split-string (delete-and-extract-region beg end) "\\b")))) (define-key evil-visual-state-map (kbd ",rw") 'reverse-words)
I've also tried
(define-key evil-normal-state-map ...) and
(define-key evil-operator-state-map ...) but to no avail.
It should also respond to the
. command to repeat the last command.
Any tips on a built-in way to do this or a better keybinding would be appreciated.