共用方式為


Walkthrough: Creating a Custom Editor

The Visual Studio Package project template can create a simple custom editor.

Prerequisites

To complete this walkthrough, you must install the Visual Studio 2010 SDK. For more information about the Visual Studio SDK, see Extending Visual Studio Overview. To find out how to download the Visual Studio SDK, see Visual Studio Extensibility Developer Center on the MSDN Web site.

Locations for the Visual Studio Package Project Template

The Visual Studio Package project template can be found in three different locations in the New Project dialog:

  1. Under Visual Basic Extensibility. The default language of the project is Visual Basic.

  2. Under C# Extensibility. The default language of the project is C#.

  3. Under Other Project Types Extensibility. The default language of the project is C++.

To create a VSPackage using the Visual Studio Package template

  1. Create a project with the Visual Studio Package template. For more information about using this template, see Walkthrough: Creating a Menu Command By Using the Visual Studio Package Template.

  2. Select the Custom Editor option and click Next. The Editor Options page is displayed.

  3. Type the name of your editor in the Editor Name box. Type the file extension that you want to be associated with your editor in the File Extension box. Your editor is available for files with this extension. The file extension is registered for Visual Studio only, not for Windows. Type the default file name for new documents created with your editor in the Default File Name box.

  4. Click Finish to create your VSPackage in the folder that you specified.

To test your custom editor

  1. On the File menu, point to New and then click File.

  2. In the Installed Templates pane of the New File dialog box, select the file template, then the file type you just registered.

  3. Click Open to view and edit the document.

    The editor supports cut-and-paste, find-and-replace, and open-and-load operations.

See Also

Other Resources

VSPackages