Editor Essentials

In many ways, the editor can be considered the heart of Visual Studio — it is where you enter and edit the code and other text used to create your applications. The Visual Studio SDK editor model not only gives you the ability to include the Visual Studio editor in your VSPackages, it also allows you to create your own custom editors or call external editors.

In addition to being used as the main code entry window, the editor is used in other places in Visual Studio where text is entered, such as the Output window and the Command window. Editors also can be form-based, as shown by the forms designer for Visual Basic.

The Visual Studio editor is a combination of several components, many of which are listed in the Terms section of this topic.

Types of Editors

First, decide what kind of editor you want to create for your VSPackage. You can choose one of the following:

  • Standard File-Based Editor — A generic text editor that saves data as files. It includes common editor functionality such as text editing, deleting, and inserting. It does not include more advanced features such as Find, Undo, or Incremental Search. Choose this editor if you need to provide simple text editing.

  • Visual Studio Core Editor — Based on the Standard File-Based Editor, the Core Editor is used by the Visual Studio integrated development environment (IDE). It contains all of the functionality of the Standard editor plus additional features such as the ability to recognize and take advantage of specific Visual Studio project types. Choose this editor if you need to provide richer text editing than the Standard File-Based Editor can provide.

  • Custom Editor — An editor specifically designed to work with a custom project type that you have created. Choose this editor if you are implementing a custom project type and you want an editor to work exclusively with your project or take advantage of its features, or you want to create a forms designer. For more information, see Walkthrough: Adding a Command to an Editor Generated by the Package Wizard and How to: Open Project-Specific Editors.

  • External Editor — Any editor in the system outside of Visual Studio, such as Notepad or Wordpad. You can call any editor in the system from your VSPackage.

For more information about choosing the best editor for your VSPackage, see Kinds of Editors.

Creating an Editor

Once you have decided on the type of editor you want for Your VSPackage, then you can create it.

Because external editors exist outside of Visual Studio, there is no standard procedure for creating them. Nevertheless, once you have an external editor, you can call it from your VSPackage. How to: Create an Editor for a VSPackage illustrates how to do this.

Terms

Here are several terms that are used to describe the programming of editors in Visual Studio SDK.

  • Buffer
    Represents a text stream and is used to read and modify text. While the buffer primarily uses Unicode, it also can read and write other text encodings.

  • Marker
    Gives certain lines of text, such as breakpoints, bookmarks, or shortcuts, a special appearance or behavior. Most markers are visible, but not all. For example, breakpoints and bookmarks each display an icon in the margin of the document (in some cases, the background color of the text is changed also), but invisible markers are used by the Visual Studio editor to return the insertion point to a line when the Undo button is clicked.

  • View
    What is generally thought of as "the text editor." An editor view is a window that displays the buffer text and allows you to navigate it and edit it with the keyboard and mouse. In windows such as the code editor, the Output window, and the Command window, editor views also allow you to make selections.

  • Logical View
    An alternate view of buffer text. Several logical views may be developed. For example, you might want to provide a hierarchical tree view of text and a view of the raw underlying text, or rendered view of HTML and a view of tagged HTML text.

  • Code Window
    A window frame (usually a MDI child) that contains one or more editor views of a buffer and displays code. For example, a code window could show a design view of underlying code, or it could have a splitter bar that splits a document into two views.

  • Text Manager
    Maintains common information and services shared by the buffer, view, code window, and other editor components). Represented by IVsTextManager and IVsTextManager2.

  • Language Service
    Handles behaviors specific to a given programming language, such as syntax coloring, statement completion, and word boundary definition.

  • Editor Factory
    Creates Editor objects for use by VSPackages.

See Also

Concepts

Kinds of Editors

Editor Design Decisions