调整VS Code中Rust可变变量下划线的位置
解决VS Code中Rust可变变量下划线干扰问题
调整下划线位置
可以通过VS Code的自定义令牌颜色配置,修改可变变量下划线的偏移量,避免和下一行内容重叠:
- 打开VS Code设置界面(快捷键
Ctrl+,或Cmd+,) - 点击界面右上角的
{}图标,打开settings.json文件 - 添加以下配置,根据需求调整
text-underline-offset的数值(负数表示向上偏移):
"editor.tokenColorCustomizations": { "[你的主题名称]": { // 示例:"[One Dark Pro]",留空则应用到所有主题 "textMateRules": [ { "scope": "variable.other.mutable.rust", "settings": { "textDecoration": "underline; text-underline-offset: -2px;" } } ] } }
提示:当前主题名称可在设置中搜索
workbench.colorTheme查看。
替换为其他高亮样式
如果调整位置效果不理想,也可以将下划线替换为加粗、背景高亮或斜体:
加粗+斜体
"editor.tokenColorCustomizations": { "[你的主题名称]": { "textMateRules": [ { "scope": "variable.other.mutable.rust", "settings": { "fontStyle": "bold italic" } } ] } }
背景高亮
"editor.tokenColorCustomizations": { "[你的主题名称]": { "textMateRules": [ { "scope": "variable.other.mutable.rust", "settings": { "background": "#ffeb3b33" // 半透明黄色,可自行调整颜色值 } } ] } }
仅加粗
"editor.tokenColorCustomizations": { "[你的主题名称]": { "textMateRules": [ { "scope": "variable.other.mutable.rust", "settings": { "fontStyle": "bold" } } ] } }
注意:若
variable.other.mutable.rust这个文本范围不生效,可按下Ctrl+Shift+P(或Cmd+Shift+P)执行「Developer: Inspect Editor Tokens and Scopes」,点击可变变量查看准确的scope值。
内容的提问来源于stack exchange,提问作者kiw
相关产品推荐
相关产品推荐

