在 VS 代码中更改光标颜色🤯

2025-06-07

在 VS 代码中更改光标颜色🤯

我使用 VSCode 已经快两年了,非常喜欢它。我相信你也会喜欢它。但我决定是时候对它进行一些自定义了。我将向你展示如何在 VSCode 中更改光标颜色。

VSCode 是一个 Electron 应用。因此,你可以在 VSCode 中随意更改 CSS 和 JS 的加载方式,为此你需要一个名为“自定义 CSS 和 JS 加载器”的扩展。

替代文本

安装扩展后,按照以下步骤更改光标的颜色。1
)将此设置添加到settings.json中。



"editor.cursorWidth": 3,
"vscode_custom_css.imports":[""],
"vscode_custom_css.policy": true,


Enter fullscreen mode Exit fullscreen mode

2)在您的机器中创建一个 CSS 文件,并将以下属性添加到该 CSS 文件。

您可以随意从uiGraients中选择您想要的任何渐变颜色,然后粘贴到“.monaco-editor .cursors-layer .cursor”选择器中。



.monaco-editor .cursors-layer .cursor {
  background: #12c2e9; 
  background: -webkit-linear-gradient(
    to top,
    #f64f59,
    #c471ed,
    #12c2e9
  ); 
  background: linear-gradient(
    to top,
    #f64f59,
    #c471ed,
    #12c2e9
  ); 
}



Enter fullscreen mode Exit fullscreen mode

3)更改settings.json中“vscode_custom_css.imports”的文件位置



  "editor.cursorWidth": 3,
  "vscode_custom_css.imports": ["file:///home/pushpak1300/Documents/vscode.css"],
  "vscode_custom_css.policy": true,


Enter fullscreen mode Exit fullscreen mode

4)输入“CMD +SHIFT +P”切换命令面板,然后输入“重新加载自定义 CSS 和 JS”以应用设置。
替代文本

5)万岁!

如果一切顺利,您应该在 vs 代码中看到渐变光标。

如果您有任何疑问,请在评论中告诉我。

图像

荣誉提名

如果您想要更多酷炫的功能,请不要忘记查看本课程。

谢谢你!

文章来源:https://dev.to/pushpak1300/change-cursor-colour-in-vs-code-2jed
PREV
学习网络安全
NEXT
Shellscripting:函数