We recommend using Visual Studio 2017

Editor Imports

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at Editor Imports.

You can import a number of editor services, factories, and brokers that provide your extension with different kinds of access to the core editor. For example, you can import the ITextStructureNavigatorSelectorService to provide you with a ITextStructureNavigator for a given content type. (This navigator allows you perform different kinds of searches on a text buffer.)

To use an editor import, you import it as a field or property of a class that exports a Managed Extensibility Framework component part.

System_CAPS_ICON_note.jpg Note

For more information about the Managed Extensibility Framework, see Managed Extensibility Framework (MEF).

The following example shows how to import the editor options factory service.

[Import]  
internal IEditorOptionsFactoryService EditorOptions { get; set; }  

If you want to import the service as a field and not a property, you should set it to null in the declaration in order to avoid the compiler warnings about not assigning to a variable:

[Import]  
internal IEditorOptionsFactoryService m_editorOptions = null;  

For more examples of using imports, see the following walkthroughs:

Walkthrough: Creating a Margin Glyph

Walkthrough: Customizing the Text View

Walkthrough: Highlighting Text

Walkthrough: Displaying QuickInfo Tooltips

Walkthrough: Displaying Signature Help

Walkthrough: Displaying Statement Completion

Walkthrough: Displaying SmartTags

You can also import a SVsServiceProvider (found in the assembly Microsoft.VisualStudio.Shell.Immutable.10.0) in the same way to get access to Visual Studio services:

[Import]  
internal SVsServiceProvider ServiceProvider = null;   

See Walkthrough: Accessing the DTE Object from an Editor Extension for more information.

Editor services are generally single entities that provide a service and are shared across multiple components.

ImportProvides
IFileExtensionRegistryServiceThe relationship between file extensions and IContentType objects.
IContentTypeRegistryServiceThe collection of IContentType objects.
IVsFontsAndColorsInformationServiceIVsFontsAndColorsInformation objects
IVsEditorAdaptersFactoryServiceMany editor adapter objects:

 IVsCodeWindow

 IVsTextBuffer

 IVsTextBufferCoordinator

 IVsTextView
IIncrementalSearchFactoryServiceAn IIncrementalSearch object for a given text view.
ITextBufferFactoryServiceAn ITextBuffer.
ITextDocumentFactoryServiceAn ITextDocument.
IDifferenceServiceAn IDifferenceCollection<T> of differences.
IHierarchicalStringDifferenceServiceAn IHierarchicalDifferenceCollection of differences.
IProjectionBufferFactoryServiceAn IProjectionBuffer or an IElisionBuffer.
IBufferGraphFactoryServiceAn IBufferGraph for a set of ITextBuffer objects.
IClassifierAggregatorServiceAn IClassifier for a ITextBuffer.
IViewClassifierAggregatorServiceAn IClassifier for a ITextView.
IClassificationFormatMapServiceAn IClassificationFormatMap for a ITextView.
IEditorFormatMapServiceAn IEditorFormatMap for a ITextView.
IClassificationTypeRegistryServiceMaintains the collection of IClassificationType objects.
IBufferTagAggregatorFactoryServiceAn ITagAggregator<T> for a text buffer.
IViewTagAggregatorFactoryServiceAn ITagAggregator<T> for a text view.
IEditorOptionsFactoryServiceThe IEditorOptions for the specified scope.
IScrollMapFactoryServiceAn IScrollMap for a text view.
ISmartIndentationServiceAn ISmartIndent for a ITextView.
ISmartIndentationServiceGets the automatic indentation through the ISmartIndentProvider objects.
ITextEditorFactoryServiceManages the IWpfTextViewHost for a IWpfTextView.
IFormattedTextSourceFactoryServiceAn IFormattedLineSource.
IRtfBuilderServiceGenerates RTF-formatted text from a set of snapshot spans.
ITextAndAdornmentSequencerFactoryServiceAn ITextAndAdornmentSequencer for an ITextView.
ITextParagraphPropertiesFactoryServiceA TextParagraphProperties for formatting text lines in a view.
IEditorOperationsFactoryServiceA IEditorOperations object for an ITextView.
ITextSearchServiceSearches a text snapshot.
ITextStructureNavigatorSelectorServiceAn ITextStructureNavigator for an ITextBuffer by IContentType.
IOutliningManagerServiceAn IOutliningManager for a text view.
IGlyphServiceA standard set of glyphs.
IIntellisenseSessionStackMapServiceAn IIntellisenseSessionStack for a ITextView.
IWpfKeyboardTrackingServiceTracks keyboard handling.
IStandardClassificationServiceStandard IClassificationType objects.
ITextUndoHistoryRegistryMaintains the relationship between text buffers and ITextUndoHistory objects.

Provider factories and brokers are generally entities that can have multiple instances in multiple components.

ImportProvides
IErrorProviderFactoryA SimpleTagger<T> of type ErrorTag) for the given buffer.
ITextMarkerProviderFactoryA text marker tagger (a SimpleTagger<T> of type TextMarkerTag).
IToolTipProviderFactoryAn IToolTipProvider for a given ITextView.
ICompletionBrokerAn ICompletionSession.
IQuickInfoBrokerAn IQuickInfoSession.
ISignatureHelpBrokerAn ISignatureHelpSession.

Language Service and Editor Extension Points

Show: