Srna Nikolic
Srna Nikolic

Reputation: 23

Visual Studio Extension -How to color code?

I am writing Visual Studio Extension Color code. My code is mix of 2 languages. Only one language is colored , so I want to color the second language and I don't know how. Is there something that allows me color code on the way I want. I want something like this code example

Which part of code provides me to color code?

Upvotes: 0

Views: 219

Answers (2)

Jason Malinowski
Jason Malinowski

Reputation: 19021

You're looking to provide what's called a "classifier". Here's one example:

https://www.codeproject.com/Articles/1245021/Extending-Visual-Studio-to-Provide-a-Colorful-Lang

In general the interface to look for is "IClassifierProvider".

Upvotes: 1

supe345
supe345

Reputation: 141

In case you are talking about Visual Studio Code:

You will have to create your own extension. To do so you can follow this guide right here. More specifically you should run this command:

npm install -g yo generator-code

And once the installation is over you run:

yo code

You should the choose New Language support and answer all the questions that will appear. Once it's done you can start defining your language. To do so you should go to the syntaxes directory and start editing the <plugin_name>.tmLanguage.json.

In this file you will normally find code examples. Here is the example of an existing Python extension.

If you pay attention there is sometimes a variable called name of this style "comment.line.number-sign.python". In order to find the possible values for this variable, I would suggest you to take a look here. The choice of this name will define the color of the matching value.

I hope this was helpful to you.

Upvotes: 0

Related Questions