In the 'normal' state of evil-mode
, cursor movement is emulating the standard behavior of vim. I want to make it more similar to the standard emacs behavior in the following two ways.
I want vertical movement to take place within visual lines, rather than logical lines. I.e. if a line is wrapped, pressing j
or <down>
should move to the next part of the same line.
I want horizontal movement to not stop at newlines. I.e. if the cursor is at the end of a line, pressing l
or <right>
should move to the next line.
How can I achieve this?
I found how to solve problem 2: It turned out there was a variable evil-cross-lines
. Setting this to t
simply solved that problem.
Together with the fix for vertical movement by PythonNut, here is the full solution:
;; Make movement keys work like they should
(define-key evil-normal-state-map (kbd "<remap> <evil-next-line>") 'evil-next-visual-line)
(define-key evil-normal-state-map (kbd "<remap> <evil-previous-line>") 'evil-previous-visual-line)
(define-key evil-motion-state-map (kbd "<remap> <evil-next-line>") 'evil-next-visual-line)
(define-key evil-motion-state-map (kbd "<remap> <evil-previous-line>") 'evil-previous-visual-line)
; Make horizontal movement cross lines
(setq-default evil-cross-lines t)