0

In vim, if i want to move 5 lines down i press J given that my xnoremap J 5j.

How do i reproduce this in emacs evil mode? The clue i have is that (define-key evil-normal-state-map "j" 'evil-next-visual-line) gets me onto the next line. How to "multiple" evil-next-visual-line symbol times 5?

4
  • I know no evil but doesn't C-u 5 j work? If it does, you can supply any multiplier you want.
    – NickD
    Commented Dec 20, 2021 at 2:34
  • @NickD Actually, in evil-normal-state-map, 5 maps to C-u 5. So 5j would be C-u 5 j like you said. And it works just fine. But I believe OP wants sth like xnoremap J 5j. It's a common cfg for people from vim background to set. :-)
    – TerryTsao
    Commented Dec 20, 2021 at 2:45
  • @TerryTsao what do you mean by a cfg? Context-free grammar?)
    – rtviii
    Commented Dec 20, 2021 at 23:42
  • 1
    @rtviii configuration. 😹
    – TerryTsao
    Commented Dec 21, 2021 at 1:53

1 Answer 1

2

From the doc:

(evil-next-visual-line &optional COUNT)

Move the cursor COUNT screen lines down.

Since lots of evil commands take an optional count (usually provided with digit-argument), you can write one easily like this:

(define-key evil-normal-state-map (kbd "J")
  (lambda nil (interactive) (evil-next-visual-line 5)))
2
  • how would i replicate this for visual/selection mode in emacs? Basically i want consistency of being able to jump 5 both when im moving around in normal and selecting a chunk in visual. Read about something called evil-motion-state-map, but just replicating the above with motion instead of normal didnt work.
    – rtviii
    Commented Dec 21, 2021 at 20:20
  • @rtviii Please try setting evil-motion-state-map for that.
    – TerryTsao
    Commented Dec 22, 2021 at 1:57

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.