Skip to content

Cursor movement

In standard Emacs terms, the cursor is generally understood to be located between two characters. In Vim, and therefore also Evil, this is the case in insert state, but in other states the cursor is understood to be `on' a character, and that this character is not a newline.

Forcing this behaviour in Emacs is the source of some potentially surprising results (especially for traditional Emacs users—users used to Vim may find the default behavior to their satisfaction). Many of them can be tweaked using the following variables.

Emacs Lisp Autovariable: evil-repeat-move-cursor

Whether repeating commands with . may move the cursor. If nil, the original cursor position is preserved, even if the command normally would have moved the cursor.

Default: t

Emacs Lisp Autovariable: evil-move-cursor-back

Whether the cursor is moved backwards when exiting insert state. If non-nil, the cursor moves “backwards” when exiting insert state, so that it ends up on the character to the left. Otherwise it remains in place, on the character to the right.

Default: t

Emacs Lisp Autovariable: evil-move-beyond-eol

Whether the cursor can move past the end of the line. If non-nil, the cursor is allowed to move one character past the end of the line, as in Emacs.

Default: nil

Emacs Lisp Autovariable: evil-cross-lines

Whether horizontal motions may move to other lines. If non-nil, certain motions that conventionally operate in a single line may move the cursor to other lines. Otherwise, they are restricted to the current line. This applies to h, SPC, f, F, t, T, ~.

Default: nil

Emacs Lisp Autovariable: evil-respect-visual-line-mode

Whether movement commands respect visual-line-mode. If non-nil, visual-line-mode is generally respected when it is on. In this case, motions such as j and k navigate by visual lines (on the screen) rather than “physical” lines (defined by newline characters). If nil, the setting of visual-line-mode is ignored.

This variable must be set before Evil is loaded.

Default: nil

Emacs Lisp Autovariable: evil-track-eol

Whether $ “sticks” the cursor to the end of the line. If non-nil, vertical motions after $ maintain the cursor at the end of the line, even if the target line is longer. This is analogous to track-eol, but respects Evil’s interpretation of end-of-line.

Default: t

Emacs Lisp Autovariable: evil-start-of-line

Analogue of vim’s startofline. If nil, preserve column when making relevant movements of the cursor. Otherwise, move the cursor to the start of the line.

Default: nil