8

Until today, when I was in the normal state in evil, the cursor was a block, and it would switch to an I-beam when in insert state. Something changed, however, and the cursor is now always the I-beam. How can I get the old behavior back?

More generally, how do I change the cursor appearance according to evil's different states?

  • 3
    An aside: A good way to find the variables Dan referenced in his answer is to use apropos. You can hit C-h a (apropos), type a search ("evil cursor"), and hit RET to find the documentation of any matching functions, variables, commands, etc. Helm has a built-in source for this as well: helm-apropos. – nanny Jan 15 '15 at 13:53
  • 1
    @nanny +1 for mentioning apropos. Note, however, that C-h a is bound to apropos-command by default, which will only list matching commands. If you want apropos-command to consider non-interactive functions, you'll have to do C-u C-h a. The apropos command (which will show both commands and variables) is not bound to a key by default. – itsjeyd Jan 15 '15 at 15:28
  • @itsjeyd: whoops, that was my bad on the keybinding. I edited @nanny's comment from apropos-command to apropos -- turns out I had rebound C-h a to apropos a long time ago, forgot, and assumed it was the default. – Dan Jan 15 '15 at 19:01
  • @Dan Oh, the pitfalls of having moderator privileges... ;) – itsjeyd Jan 15 '15 at 19:32
10

The variable cursor-type controls how the appearance of the cursor, defaulting to t, which uses the cursor specified for the frame (see the docstring for options). If you'd like the cursor to default to a block, you can (setq cursor-type 'box).

However, evil provides a number of different cursors for the different states, which you can adjust to give you a visual reminder of what state you're in when you're typing:

  • evil-normal-state-cursor
  • evil-insert-state-cursor
  • evil-visual-state-cursor
  • evil-motion-state-cursor
  • evil-replace-state-cursor
  • evil-operator-state-cursor

The docstring states that each of these:

May be a cursor type as per cursor-type, a color string as passed to set-cursor-color, a zero-argument function for changing the cursor, or a list of the above.

So, for example, if you wanted a yellow bar 5 pixels wide in insert state and a purple-filled box in normal state, you could do the following:

(setq evil-insert-state-cursor '((bar . 5) "yellow")
      evil-normal-state-cursor '(box "purple"))

See the docstring for cursor-type for your options in adjusting the cursor.

  • Do you know by any chance, how to configure the cursor for minibuffer? Seems like it always stays as it is configured for normal mode. – Yuki Oct 3 '18 at 15:02
  • @Yuki: if you mean the appearance, I do not know off the top of my head. If you want evil bindings in the minibuffer, follow the links in the discussion on this post and/or take a look at this github gist. – Dan Oct 3 '18 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.