问:vscode能不能把同一个单词标记上颜色?
答:
能,叫做 选中高亮
问:对的。但是我想不选中的时候,也高亮
答:这个叫做:代码高亮 -》 符合一定规则 用特定颜色显示
-》上面这种 所有write都用 黄色背景显示
-》但是导致不是write的其他函数 也都是 黄色高亮
-》不知道是不是你要的效果了
VSCode 默认已支持 常见的 所有的 编程语言的代码的 高亮
你上面的截图 -》 明显是SourceInsight(典型是开发嵌入式Linux看linux内核源码时的用的 代码查看的工具)的效果 -》 上面的 write 也是 选中后 才高亮的
如果不选中就都高亮 那所有函数都高亮 -》 效果上可以说是 亮瞎你的(钛合金狗)眼
导致看不清函数 无法正常使用
问:是的。
厉害了,这都能看出来
答:所以:你要说你想要什么东西 把具体背景解释清楚
我才好帮你想办法
问:你上面的截图 -》 明显是SourceInsight(典型是开发嵌入式Linux看linux内核源码时的用的 代码查看的工具)的效果 -》 上面的 write 也是 选中后 才高亮的 就是这个
注:
这些是之前折腾的Source Insight相关的记录:
【已解决】去除已经安装的Source Insight序列号/注册码 – 在路上
【记录】想办法让试用30天后过期的Source Insight可以继续重新开始有30天的试用 – 在路上
拷贝Source Insight中的彩色代码的方法|将Source Insight的着色代码拷贝出来(到Word里面)的办法 – 在路上
VSCode中,默认已经支持 选中的单词(函数,类名等) 高亮指示了
-》只不过默认是白色的
那其实问题转换为:
-》如何把VSCode中选中的颜色 换成黄色高亮的效果
-》搜
VSCode 选中 黄色高亮
-》
VS Code修改选中文字或代码的颜色 – 天马3798 – CSDN博客
去设置试试:
搜:
colorCustomizations
没有找到要的:
editor.selectionBackground
vscode 选中后相同内容高亮插件推荐 – palmer_kai的博客 – CSDN博客
下载插件
highlight-icemode
vscode selection highlight color
Change highlight text color in Visual Studio Code – Stack Overflow
"workbench.colorCustomizations": { "editor.selectionBackground": "#135564", "editor.selectionHighlightBackground": "#135564" },
去试试:
搜:
color
粘贴过去:
"workbench.colorCustomizations": { "editor.selectionBackground": "#135564", "editor.selectionHighlightBackground": "#135564" }
然后可以定制颜色:
可以看到上面是墨绿色:
点击换成:
前景色:黑色
背景色:黄色
"workbench.colorCustomizations": {
“editor.selectionBackground”: “#010607fb”,
“editor.selectionHighlightBackground”: “#b6f703”
}
结果不好看
又换了点其他颜色:
"workbench.colorCustomizations": { "editor.selectionBackground": "#011114fb", "editor.selectionHighlightBackground": "#e0dd15" }
还是不合适。
去取色:
转换后:
前景色:RGB(1,1,0)
#010100
背景色:RGB(193,191,42)
#C1BF2A
后来发现不对,去参考:
Could I change the color of occurrences highlight? · Issue #24034 · Microsoft/vscode
继续加上:editorSelection
"workbench.colorCustomizations": { "editor.editorSelection": "#010100", "editor.selectionBackground": "#C1BF2A", "editor.selectionHighlightBackground": "#C1BF2A", }
结果:
选中的颜色并不是设置的黑色-》没起效果。
Theme Color | Visual Studio Code Extension API
“* editor.selectionBackground: Color of the editor selection.
* editor.selectionForeground: Color of the selected text for high contrast.
* editor.inactiveSelectionBackground: Color of the selection in an inactive editor. The color must not be opaque so as not to hide underlying decorations.
* editor.selectionHighlightBackground: Color for regions with the same content as the selection. The color must not be opaque so as not to hide underlying decorations.
* editor.selectionHighlightBorder: Border color for regions with the same content as the selection.”
结果始终不对:
无法设置选中内容的前景色
vscode selection foreground color
“selectionForeground would be very difficult implement given that in our editor selection and text are two different layers. @alexandrudima Alex, correct me if I lie.
Also from what I read, selectionForeground seems to be a customization, not even supported by TextMate. So I’d suggest to close this request as ‘won’t fix’.”
好像不支持?
vscode 高亮的前景色
前端 – 请问如何更改vscode 选中文字或代码的的颜色? – SegmentFault 思否
试试:
"workbench.experimental.colorCustomizations": { "editorSelection": "#E0DBC9" }
和:
"workbench.colorCustomizations": { "editor.selectionBackground": "#135564" }
不行。
VS2012高亮显示当前行背景色的问题 – Edi.Wang
对于选中内容的前景色,后来发现一个,部分的解决方案:
更换主题
比如从:
(默认的)Default Dark+
换成
Default Light+
即可:
实现,使得选中的内容的颜色,变成想要的黑色了:
同时也注意到了,当前配置加了个:
"workbench.colorTheme": "Default Light+"
【总结】
想要设置,选中的内容,黄色高亮显示,可以
Code-》首选项-》设置
-》搜color,找到:
Workbench:Color Customizations
点击:在 settings.json 中编辑
加上配置:
"workbench.colorCustomizations": { "editor.selectionBackground": "#f5f113", "editor.selectionHighlightBackground": "#f5f113", },
就可以实现想要的
指定选中的内容的背景色
的效果:
不过对于 选中的文字的颜色=前景色,由于内置机制原因,无法单独
(通过:
"editor.selectionForeground": "#010100",
或:
"editorCursor.foreground": "#ff0000",
之类的的参数去)设置。
而如果非要换选中内容的颜色,可以通过更换主题实现。
比如,主题从:
(默认的)Default Dark+
换成
Default Light+
注:对应配置文件中会自动新增配置:
"workbench.colorTheme": "Default Light+",
则 选中的文字的前景色就是黑色(系列)了:
【后记】
用如下配置:
"workbench.colorCustomizations": { "editor.selectionBackground": "#800080", "editor.selectionHighlightBackground": "#4169E1", },
在Dark主题中的效果是:
选中的部分的背景颜色
(同文件中,和)选中的部分(内容相同)的其他部分的背景颜色
选中大段内容后的效果:
注:
选择颜色,可以去这里找: