1
votes

Consider the following piece of code:

(goto-char (point-max))
(insert "\n")

In normal state of evil-mode goto-char moves the cursor to the end of line visually, but it points before the last symbol, not after. Although the example above works just fine — it works as if the cursor is pointing after the last symbol so the last symbol is not carried to the next line which is a correct behavior. I wonder how evil determines that it needs to insert after the last symbol, not before.

The reason I ask about this is because I am trying to understand why hitting enter in haskell-mode repl in normal state in evil-mode puts the last symbol of the current line on the next line. It looks like (insert "\n") is invoked in a callback and evil doesn't know that it needs to maintain the compatibility.

1

1 Answers

1
votes

It's not entirely clear what the question is, but I presume you want to avoid moving the last character to the next line upon hitting enter.

To mimic Vim's behavior, the cursor moves back a point after exiting insert state. As a by-product, (insert "\n") at the end of the line occurs just before the character on which the cursor is sitting, which puts it before the newline.

To disable this compatibility feature, do (setq evil-move-cursor-back nil) (or use setq-local if you only want to disable in the REPL) and you should be able to avoid putting the last symbol on the next line.