Kinds of Editors

If users of your VSPackage need to write code or text, or place controls on forms, you can add an editor to your VSPackage to enable them to do so. The Visual Studio integrated development environment (IDE) handles four different types of editors:

  • Standard File Based Editor

  • Visual Studio Core Editor (the editor used by Visual Studio)

  • Custom Editor

  • External Editor

Visual Studio Core Editor

The Visual Studio core editor is used to enter and edit source code for projects. Because it can be used to enter code of different programming languages, it is not associated with any one project type. The IDE instantiates the core editor whenever it opens or creates a file that has a registered extension.

To enable your VSPackage to use an instance of the Visual Studio core editor, you first create an editor factory by implementing IVsEditorFactory. (For more information about class factories, see Implementing a Class Factory.) You then add information about the editor factory to the registry so that it is recognized by Visual Studio. For more information, see Core Editor.

Standard File-Based Editor

Like the Visual Studio core editor, a standard file-based editor is not associated with any particular project type. Unlike the core editor, however, standard editors can accommodate special file formats. Choose a standard editor if your project type does not require customizations beyond those required by other Visual Studio projects.

To create a standard editor, you first create an editor factory by implementing IVsEditorFactory. Then, you implement the IVsPersistDocData2 interface to enable projects to notify the document when to save its current state.

Views for standard editors can be implemented in either of two ways — first, as an in-place activation editor that uses an ActiveX control or a document window that contains text or a designer or, second, as a simplified embedding editor where the editor's window handle is a parent of the Visual Studio window.

For more information, see Document Windows and Editors.

Custom Editor

A custom editor is one that is designed to work with a new type of project you have created. For example, you might create an editor whose function is to read and write data to a specific repository, such as Microsoft Exchange server. Choose a custom editor if you want an editor that works with your project type only or if you want an editor that has only a few specific commands. Note, however, that users will not be able to use a custom editor to edit standard Visual Studio projects.

A custom editor can use an editor factory and add information about the editor factory to the registry. However, the project type associated with the custom editor can instantiate the custom editor in other ways.

A custom editor can use either in-place activation or simplified embedding to implement a view.

External Editor

External editors are editors on the system that are not integrated into Visual Studio, such as Microsoft Word, Notepad, or Microsoft FrontPage. You might call such an editor if, for example, you are passing text to it from your VSPackage. External editors register themselves and can be used outside the Visual Studio IDE. When you call an external editor, and it can be embedded in a host window, then it appears in a window in the IDE. If not, then the IDE creates a separate window for it.

The IsDocumentInProject method sets the document priority by using the VSDOCUMENTPRIORITY enumeration. If the DP_External value is specified, the file can be opened by an external editor.

See Also

Concepts

Editor Design Decisions

Reference

IVsEditorFactory

IVsPersistDocData

Other Resources

Core Editor