

In the constructor for HighlightWordTag, pass in the name of the format definition you created. The Background property defines the fill color, while the Foreground property defines the border color. In the constructor for HighlightWordFormatDefinition, define its display name and appearance. Internal class HighlightWordFormatDefinition : MarkerFormatDefinition UserVisibleAttribute: this causes the format to appear in the UI NameAttribute: tags use this to reference this format In order to use this format definition for your tag, you must export it with the following attributes:

internal class HighlightWordTag : TextMarkerTagĬreate a second class that inherits from MarkerFormatDefinition, and name it HighlightWordFormatDefinition. Using Ĭreate a class that inherits from TextMarkerTag and name it HighlightWordTag. To define a TextMarkerTag and a MarkerFormatDefinitionĪdd a class file and name it HighlightWordTag. The first step in highlighting text is to subclass TextMarkerTag and define its appearance. For more information, see Create an extension with an editor item template. (In the New Project dialog, select Visual C# / Extensibility, then VSIX Project.) Name the solution HighlightWordTest.Īdd an Editor Classifier item template to the project. Create a MEF projectĬreate a C# VSIX project. For more information, see Install the Visual Studio SDK. You can also install the VS SDK later on. It's included as an optional feature in Visual Studio setup. Starting in Visual Studio 2015, you don't install the Visual Studio SDK from the download center.

If a word occurs more than one time in a text file, and you position the caret in one occurrence, every occurrence is highlighted. This walkthrough shows how to highlight every occurrence of the current word in a text file. You can add different visual effects to the editor by creating Managed Extensibility Framework (MEF) component parts. Applies to: Visual Studio Visual Studio for Mac Visual Studio Code
