I would like to change the shape of the cursor to something like the following image:
It's a bit taller and thicker than the default one. How do I do that?
You can customize the value of cursor-type
:
Documentation: Cursor to use when this buffer is in the selected window. Values are interpreted as follows:
t
use the cursor specified for the frame
nil
don't display a cursor
box
display a filled box cursor
hollow
display a hollow box cursor
bar
display a vertical bar cursor with default width
(bar . WIDTH)
display a vertical bar cursor with width WIDTH
hbar
display a horizontal bar cursor with default height
(hbar . HEIGHT)
display a horizontal bar cursor with height HEIGHTANYTHING ELSE display a hollow box cursor
It looks like you want something like (setf cursor-type 'bar)
setf
? (setq cursor-type '(bar . 4))
works just fine. I am asking because I don't know why one would do setf
instead of setq
; and I have never used setf
:).
Commented
Jul 27, 2015 at 14:40
setf
is actually a macro that will expand into setq
in this situation. I had been learning Common Lisp, where setf
is used pervasively, and now use it when my mind's on auto-pilot.
setf
in Common Lisp, but it would be more idiomatic to use setq
in Emacs Lisp. There is no difference of course, but people are generally expecting setq
, so setf
may confuse some people without Common Lisp background. For example, I love functional programming, but when I need to do Python, I will write [x for x in S if P(x)]
instead of filter(P, S)
-- which is clearer, no matter what creator of Python thinks :-D
Commented
Jul 27, 2015 at 16:01
setf
only when it's really useful, i.e. when its argument is some compound structure. But even in that case, setcar
may be better than (setf (car ...) ...)
in Emacs Lisp.
Commented
Jul 27, 2015 at 16:02
you can do something like, to change both width and color
(setq evil-insert-state-cursor '((bar . 4 ) "orange" ))