简体   繁体   English

如何在 VS Code 中为 C# 设置用户定义的突出显示

[英]How can I make user-defined highlight for C# in VS Code

Recently I installed VS Code and C# plugin for it.最近我为它安装了 VS Code 和 C# 插件。 I must say that I really like the editor.我必须说我真的很喜欢这个编辑器。 It is very lightweight and highly customizable.它非常轻巧且高度可定制。 However I haven't found how can I redefine several colorization options such as highlighting classes inside field definitions or local variables?但是我还没有找到如何重新定义几个着色选项,例如突出显示字段定义或局部变量中的类?

I already use standard C# colorizer.我已经在使用标准的 C# 着色器。 I just want to customize the color of some lexemes, not everything.我只是想自定义一些词素的颜色,而不是一切。

Checkout the docs here:在此处查看文档:

https://code.visualstudio.com/Docs/customization/colorizer https://code.visualstudio.com/Docs/customization/colorizer

You basically either get one from the marketplace or generate a basic editable file with yeoman.您基本上要么从市场上获得一个,要么使用 yeoman 生成一个基本的可编辑文件。

You can also add themes even from color sublime as described here:您甚至可以从 color sublime 中添加主题,如下所述:

https://code.visualstudio.com/docs/customization/themes https://code.visualstudio.com/docs/customization/themes

Install theme from extensions from which you wish to start.从您希望开始的扩展安装主题。

Then find where the theme got installed.然后找到安装主题的位置。 On Windows it would be %USERPROFILE%\\.vscode\\extensions , see details inInstalling extensions .在 Windows 上,它将是%USERPROFILE%\\.vscode\\extensions ,请参阅安装扩展中的详细信息。

There you'll find folder with theme, inside is themes folder and <something>.tmTheme file which is actually xml file.在那里你会找到带有主题的文件夹,里面是themes文件夹和<something>.tmTheme文件,它实际上是 xml 文件。 Open it inside VSCode and start editing :)在 VSCode 中打开它并开始编辑 :)

You'll find items and colors, syntax is described elsewhere, but common sense will help you.你会找到项目和颜色,语法在别处描述,但常识会帮助你。

To test change, open desired .cs file in same editor.要测试更改,请在同一编辑器中打开所需的 .cs 文件。 Changes are applied after restart, so it's also good to make key shortcut to restart the editor:重新启动后会应用更改,因此也可以使用快捷键来重新启动编辑器:

keybindings.json键绑定.json

...
{
   "key": "ctrl+shift+alt+r",
   "command": "workbench.action.reloadWindow"
}
...

Then try color, restart, see result, continue...然后尝试颜色,重新启动,查看结果,继续...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C# Outlook 插件:如何以编程方式删除用户定义的属性? - C# Outlook Add-in: How can I delete a User-defined property programmatically? 有没有办法对我无法编写代码的类进行用户定义的转换? - Is there a way to make a user-defined conversion for a class that I can't write code to? 在利用OAuth代码流时,如何使用用户定义的唯一标识符注册新用户? - How can I register a new user with a user-defined unique identifier when leveraging OAuth code flow? 在 C# 中,如何在编译时不知道类型的情况下访问用户定义类型的 static 属性? - In C#, how can you access a static property of a user-defined type without knowing the type at compiletime? 在 C# 中如何使用和创建用户定义的委托? - How are user-defined delegates used and created in C#? C#中如何判断一个属性是否为自定义类型? - How do I determine if a property is a user-defined type in C#? 如何在 Visual Studio 中将 Oracle 用户定义类型导出为 C# 类? - How do I export an Oracle User-defined Type as a C# class in Visual Studio? 记录用户定义的异常C# - Logging user-defined exception C# 如何在 xamarin 的 SQLite 中创建用户定义的函数? - How can I create a user-defined function in SQLite in xamarin? VS2010不符合C#4.0规范中的“用户定义的转换评估”吗? - Does VS2010 not comply with “Evaluation of user-defined conversions” in C# 4.0 spec?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM