listening-text-view-events

Implement Visual Studio text view listeners for editor lifecycle events.

14|2|Updated Mar 24, 2026
One-click install
npx skills add https://github.com/madskristensen/vs-agent-plugins --skill listening-text-view-events
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: listening-text-view-events
Source: https://github.com/madskristensen/vs-agent-plugins/tree/main/skills/listening-text-view-events
Command: npx skills add https://github.com/madskristensen/vs-agent-plugins --skill listening-text-view-events

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Visual Studio extensions often need to initialize per-editor state and respond to editor lifecycle events such as open, close, and content changes. This skill guides you through implementing text view listeners across the three extensibility models (VisualStudio.Extensibility, VSIX Community Toolkit, and VSSDK), enabling reliable per-editor behavior.

Core Features & Use Cases

  • Listen for editor open/close events to initialize or clean up per-document state.
  • React to text changes within an editor to trigger live analysis or decorations.
  • Support multiple models (out-of-process, in-process Toolkit, and MEF-based VSSDK) with proper cleanup and filtering.

Quick Start

Register a text view listener suitable for your extension model and start handling editor open/close and text-change events.

Frequently Asked Questions about listening-text-view-events

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I listen to text view events in a Visual Studio extension?

Listen to text view events by implementing ITextViewOpenClosedListener or ITextViewChangedListener using MEF-based listeners, enabling extensions to react to editor open, close, and content changes across Visual Studio extensibility models.

How do I track live text changes in a Visual Studio editor?

Track live text changes by implementing ITextViewChangedListener to react to content modifications within an editor, allowing extensions to trigger live analysis or apply decorations during active editing sessions.

Can I use text view listeners with the out-of-process VisualStudio.Extensibility model?

Text view listeners support the out-of-process VisualStudio.Extensibility model, alongside the in-process VSIX Community Toolkit and MEF-based VSSDK, enabling consistent per-editor lifecycle event handling across different extension architectures.

How do I initialize per-editor state when a document opens in Visual Studio?

Initialize per-editor state by registering a text view listener to handle editor open events, allowing extensions to set up per-document resources and UI integration immediately when a text view is created.

Why do Visual Studio extensions leak memory when handling editor events?

Extensions leak memory when editor lifecycle listeners lack proper filtering and cleanup. Implementing correct disposal for per-editor state when handling close events prevents resource leaks in Visual Studio extensions.

What is the best way to handle editor lifecycle events across multiple Visual Studio extensibility models?

Handle editor lifecycle events by implementing MEF-based text view listeners with proper filtering and cleanup, providing a unified approach for per-editor initialization and live-change tracking across out-of-process, in-process, and legacy VSSDK models.