如何更改光标类型和颜色?


23

我想像在终端中那样将光标从块更改为I型光束光标。

由此:

块

对此:

伊比姆

我该怎么做?

另外,在侧面说明中,如何更改光标的颜色?

Answers:


40

为了更改光标或插入符号,您想要做的是:

打开您的.emacs文件和以下代码行:

(setq-default cursor-type 'bar) 

并更改颜色:

(set-cursor-color "#ffffff") 

当然,您可以更改#ffffff为任何十六进制颜色。


1
刚刚在kuler看到了许多漂亮的颜色,但我认为没有参考,您的回答会更好。
remvee 2014年

11

可以为给定的缓冲区设置游标类型(使用局部缓冲区变量cursor-type),如@King的答案所示。(该答案用于setq-default设置所有缓冲区的默认值。)

或者可以为给定的将其设置为frame参数cursor-type

通过将其添加到option中,可以将其设置为所有帧的默认光标类型default-frame-alist。例如,将此项目添加到列表中:(cursor-type . bar)

这是一条命令(来自库oneonone.el),用于设置当前帧的光标类型:

(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))))

光标颜色始终是每帧的,而不是每个缓冲区的。

在库中,oneonone.el您还将找到在只读和可写之间,在覆盖模式和插入模式之间切换缓冲区时自动更改游标类型的选项,或者在Emacs空闲时将其更改为框形游标(更明显)的选项。 。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.