23

I would like to change the cursor, like in Terminal, from the block to the I-Beam cursor.

From this:

Block

To this:

Ibeam

How would I do this?

Also, on a side note, how do I change the color of the cursor?

40

In order to change your cursor or caret, what you want to do is:

Open your .emacs file and this line of code:

(setq-default cursor-type 'bar) 

And to change the color:

(set-cursor-color "#ffffff") 

Of course, you can change #ffffff to any hexadecimal color.

  • 1
    Just saw a lot of pretty colors at kuler but I think your answer is better without the reference. – remvee Sep 28 '14 at 17:09
11

Cursor type can be set for a given buffer (using buffer-local variable cursor-type), as indicated in the answer by @King. (That answer uses setq-default to set the default value for all buffers.)

Or it can be set for a given frame, as frame parameter cursor-type.

You can set it the default cursor type for all frames by adding it to option default-frame-alist. For example add this item to the alist: (cursor-type . bar).

Here is a command (from library oneonone.el) to set the cursor type for the current frame:

(defun 1on1-set-cursor-type (cursor-type)
  "Set the cursor type of the selected frame to CURSOR-TYPE.
When called interactively, prompt for the type to use.
To get the frame's current cursor type, use `frame-parameters'."
  (interactive
   (list (intern (completing-read
                   "Cursor type: "
                   (mapcar 'list '("box" "hollow" "bar" "hbar" nil))))))
  (modify-frame-parameters (selected-frame) (list (cons 'cursor-type cursor-type))))

Cursor color is always per-frame, not per-buffer.

In library oneonone.el you will also find options to automatically change the cursor type when you switch a buffer between read-only and writable, or between overwrite mode and insert mode, or to change the type to a box cursor (more noticeable) when Emacs is idle.

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.