/vs-extensibility-skills:creating-editor-taggersfrom vs-extensibility-skills
Guides adding squiggle, outlining, and text marker tags to Visual Studio editors via ITagger/ITaggerProvider. Includes MEF setup and multiple SDK approaches.
Ships in vs-extensibility-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Taggers annotate text spans with tags that drive editor features: squiggles (error/warning underlines), outlining (code folding), text markers, classification, and more. The ITagger<T> / ITaggerProvider pattern is the core mechanism behind many editor visuals.
Common scenarios:
Taggers are the lowest-level building block in the VS editor extensibility model — classifiers, adornments, margins, and light bulb features depend on tag data. A tagger's GetTags runs on the UI thread during every render pass, making performance the primary concern.
When to use taggers vs. alternatives:
IErrorTag (this skill) — or Roslyn DiagnosticAnalyzer for C#/VBIOutliningRegionTag (this skill)IGlyphFactory (see vs-editor-margin).vsixmanifestITagger<T>)IViewTaggerProvider or ITaggerProvider)Any extension that uses MEF editor exports must declare the MEF asset type in the .vsixmanifest file. Without this, Visual Studio will not discover your MEF components and your tagger will not load.
Add this inside the <Assets> element of source.extension.vsixmanifest:
<Asset Type="Microsoft.VisualStudio.MefComponent"
d:Source="Project"
d:ProjectName="%CurrentProject%"
Path="|%CurrentProject%|" />
The VisualStudio.Extensibility SDK does not currently support custom taggers. Taggers are in-process MEF components.
For diagnostics (error/warning squiggles), the new model supports diagnostics through language server protocol (LSP) or Roslyn analyzers, which is the recommended approach for reporting errors in the new model.
For custom taggers, use the VSSDK (in-process) MEF approach.
The Community Toolkit does not wrap the tagger API — taggers use the standard VSSDK MEF pattern described below.
NuGet packages: Microsoft.VisualStudio.SDK, Microsoft.VisualStudio.Editor, Microsoft.VisualStudio.Text.UI.Wpf
Key namespaces: Microsoft.VisualStudio.Text.Tagging, Microsoft.VisualStudio.Text.Editor, Microsoft.VisualStudio.Utilities
IErrorTagusing System;
using System.Collections.Generic;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Adornments;
using Microsoft.VisualStudio.Text.Tagging;
namespace MyExtension;
internal sealed class ErrorTagger : ITagger<IErrorTag>
{
private readonly ITextBuffer _buffer;
public ErrorTagger(ITextBuffer buffer)
{
_buffer = buffer;
_buffer.Changed += (s, e) => OnBufferChanged(e);
}
public event EventHandler<SnapshotSpanEventArgs> TagsChanged;
public IEnumerable<ITagSpan<IErrorTag>> GetTags(NormalizedSnapshotSpanCollection spans)
{
foreach (var span in spans)
{
string text = span.GetText();
int index = 0;
// Example: flag "FIXME" as warnings
while ((index = text.IndexOf("FIXME", index, StringComparison.OrdinalIgnoreCase)) >= 0)
{
var errorSpan = new SnapshotSpan(span.Start + index, 5);
yield return new TagSpan<IErrorTag>(
errorSpan,
new ErrorTag(PredefinedErrorTypeNames.Warning, "FIXME found — address this issue"));
index += 5;
}
}
}
private void OnBufferChanged(TextContentChangedEventArgs e)
{
foreach (var change in e.Changes)
{
TagsChanged?.Invoke(this,
new SnapshotSpanEventArgs(new SnapshotSpan(
e.After, change.NewSpan)));
}
}
}
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Utilities;
namespace MyExtension;
[Export(typeof(ITaggerProvider))]
[ContentType("text")]
[TagType(typeof(IErrorTag))]
internal sealed class ErrorTaggerProvider : ITaggerProvider
{
public ITagger<T> CreateTagger<T>(ITextBuffer buffer) where T : ITag
{
return buffer.Properties.GetOrCreateSingletonProperty(
() => new ErrorTagger(buffer)) as ITagger<T>;
}
}
Use PredefinedErrorTypeNames for squiggle styles:
| Constant | Squiggle Color |
|---|---|
PredefinedErrorTypeNames.SyntaxError | Red squiggle |
PredefinedErrorTypeNames.CompilerError | Red squiggle |
PredefinedErrorTypeNames.Warning | Green squiggle |
PredefinedErrorTypeNames.Suggestion | Gray dots |
PredefinedErrorTypeNames.HintedSuggestion | Faint dots |
IOutliningRegionTagusing System;
using System.Collections.Generic;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Tagging;
namespace MyExtension;
internal sealed class OutliningTagger : ITagger<IOutliningRegionTag>
{
private readonly ITextBuffer _buffer;
public OutliningTagger(ITextBuffer buffer)
{
_buffer = buffer;
_buffer.Changed += (s, e) => TagsChanged?.Invoke(this,
new SnapshotSpanEventArgs(new SnapshotSpan(e.After, 0, e.After.Length)));
}
public event EventHandler<SnapshotSpanEventArgs> TagsChanged;
public IEnumerable<ITagSpan<IOutliningRegionTag>> GetTags(
NormalizedSnapshotSpanCollection spans)
{
if (spans.Count == 0)
yield break;
ITextSnapshot snapshot = spans[0].Snapshot;
string openKeyword = "#region";
string closeKeyword = "#endregion";
var startLines = new Stack<ITextSnapshotLine>();
foreach (ITextSnapshotLine line in snapshot.Lines)
{
string text = line.GetText().TrimStart();
if (text.StartsWith(openKeyword, StringComparison.OrdinalIgnoreCase))
{
startLines.Push(line);
}
else if (text.StartsWith(closeKeyword, StringComparison.OrdinalIgnoreCase)
&& startLines.Count > 0)
{
var startLine = startLines.Pop();
var regionSpan = new SnapshotSpan(startLine.Start, line.End);
// Collapsed text shown when region is folded
string headerText = startLine.GetText().Trim();
yield return new TagSpan<IOutliningRegionTag>(
regionSpan,
new OutliningRegionTag(
isDefaultCollapsed: false,
isImplementation: true,
collapsedForm: headerText,
collapsedHintForm: regionSpan.GetText()));
}
}
}
}
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Utilities;
namespace MyExtension;
[Export(typeof(ITaggerProvider))]
[ContentType("text")]
[TagType(typeof(IOutliningRegionTag))]
internal sealed class OutliningTaggerProvider : ITaggerProvider
{
public ITagger<T> CreateTagger<T>(ITextBuffer buffer) where T : ITag
{
return buffer.Properties.GetOrCreateSingletonProperty(
() => new OutliningTagger(buffer)) as ITagger<T>;
}
}
TextMarkerTagText marker tags highlight spans with a background/foreground color using a predefined format:
using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Tagging;
namespace MyExtension;
internal sealed class HighlightTagger : ITagger<TextMarkerTag>
{
private readonly ITextBuffer _buffer;
private readonly string _searchWord;
public HighlightTagger(ITextBuffer buffer, string searchWord)
{
_buffer = buffer;
_searchWord = searchWord;
}
public event EventHandler<SnapshotSpanEventArgs> TagsChanged;
public IEnumerable<ITagSpan<TextMarkerTag>> GetTags(
NormalizedSnapshotSpanCollection spans)
{
foreach (var span in spans)
{
string text = span.GetText();
int index = 0;
while ((index = text.IndexOf(_searchWord, index, StringComparison.OrdinalIgnoreCase)) >= 0)
{
var matchSpan = new SnapshotSpan(span.Start + index, _searchWord.Length);
// Use a built-in format name or define your own EditorFormatDefinition
yield return new TagSpan<TextMarkerTag>(
matchSpan,
new TextMarkerTag("MarkerFormatDefinition/HighlightWordFormatDefinition"));
index += _searchWord.Length;
}
}
}
}
| Tag Interface | Purpose |
|---|---|
IErrorTag | Error/warning squiggles |
IOutliningRegionTag | Code folding regions |
TextMarkerTag | Background/foreground text highlights |
IClassificationTag | Classification-based coloring (alternative to IClassifier) |
IUrlTag | Clickable URL hyperlinks |
ITextMarkerTag | General-purpose text markers |
IStructureTag | Code block structure visualization |
GetTags is called frequently during scrolling and editing — keep it fast.TagsChanged only for the specific spans that changed, not the entire document.buffer.Properties.GetOrCreateSingletonProperty to ensure one tagger per buffer.[TagType] attribute on the provider tells the editor which tag type your tagger produces.[ContentType] attribute scopes your tagger to specific file types.ITextView), implement IViewTaggerProvider instead..vsixmanifest — see the top of this document.ITagger<T> and export ITaggerProvider via MEF. Choose the tag type based on the visual you need (squiggles, outlining, markers).source.extension.vsixmanifest.GetTags runs on the UI thread — avoid expensive computation. Parse on a background thread and cache results.TagsChanged to signal the editor to re-query your tagger..vsixmanifest. Verify [ContentType] and [TagType] attributes on the provider match the file type and tag type.TagsChanged when your cached data updates. The editor won't re-query without this event.GetTags is doing too much work. Parse on a background thread and read from cache in GetTags.ITrackingSpan or translate with snapshot.CreateTrackingSpan.IViewTaggerProvider when ITaggerProvider would suffice. IViewTaggerProvider creates one tagger per view; ITaggerProvider creates one per buffer.Do NOT use custom
ITagger<IErrorTag>for C#, VB, or languages with Roslyn/LSP support — use Roslyn analyzers or LSPtextDocument/publishDiagnosticsinstead. They integrate with Error List and support code fixes.
Do NOT do parsing, regex, file I/O, or allocations in
GetTags— it runs on the UI thread every scroll/edit. Parse on a background thread and cache results;GetTagsshould only read from cache.
Do NOT fire
TagsChangedfor the entire document when only a few spans changed — pass only the affectedSnapshotSpanto avoid unnecessary re-rendering.
Do NOT forget to raise
TagsChangedwhen cached data updates — without it, stale squiggles/markers remain on screen.
Do NOT forget
[TagType]or[ContentType]on yourITaggerProvider— missing attributes cause silent load failure.
Do NOT forget the
MefComponentasset type in.vsixmanifest— without it, your tagger provider is silently ignored.
Do NOT confuse
ITaggerProvider(buffer-level) withIViewTaggerProvider(view-level) — useIViewTaggerProvideronly when you needITextViewaccess.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
editor-taggers, visual-studio-extensions, squiggles, outlining, itagger
Generated from the plugin's indexed repository (madskristensen/vs-agent-plugins) — no native marketplace selected
npx claudepluginhub p/madskristensen-vs-extensibility-skills41 skills in this plugin
/adding-codelens-indicatorsAdd custom CodeLens indicators that display inline information above code elements in the Visual Studio editor. Use when the user asks how to add a CodeLens indicator, show inline data above methods or classes, create a custom CodeLens provider, implement IAsyncCodeLensDataPointProvider, display git history or test status in CodeLens, or add a details popup to CodeLens entries. Covers VSSDK / VSIX Community Toolkit (in-process + out-of-process CodeLens service). VisualStudio.Extensibility (out-of-process) does not have a dedicated CodeLens API./adding-commandsAdd commands (menu items, toolbar buttons) to Visual Studio extensions. Use when the user asks how to create a command, add a menu item, add a toolbar button, register a command handler, wire up a .vsct file, use KnownMonikers icons on buttons, or place commands in menus/toolbars in a Visual Studio IDE extension. Covers VisualStudio.Extensibility (out-of-process), VSIX Community Toolkit (in-process), and legacy VSSDK (in-process) approaches./adding-context-menusAdd native-looking context menus to custom WPF UI in Visual Studio extensions (tool windows, custom tree views, list views). Use when the user wants to show a right-click context menu from their own UI that looks native to VS. Covers defining VSCT context menus (type="Context"), grouping commands with separators, and programmatically showing them via IVsUIShell.ShowContextMenu. Do NOT use regular WPF ContextMenu — it won't match VS theming or support command routing. Covers VSSDK and VSIX Community Toolkit (in-process). VisualStudio.Extensibility (out-of-process) does not support VSCT-based context menus on custom UI.Other plugins' skills for the same job