ExpansionProvider.InsertNamedExpansion Method (IVsTextView, String, String, TextSpan, Boolean)


Inserts the specified snippet into the source at the given position.

Namespace:   Microsoft.VisualStudio.Package
Assembly:  Microsoft.VisualStudio.Package.LanguageService.14.0 (in Microsoft.VisualStudio.Package.LanguageService.14.0.dll)

public virtual bool InsertNamedExpansion(
	IVsTextView view,
	string title,
	string path,
	TextSpan pos,
	bool showDisambiguationUI


Type: Microsoft.VisualStudio.TextManager.Interop.IVsTextView

[in] An IVsTextView object representing the view showing the source.

Type: System.String

[in] A string containing the name or title of the snippet.

Type: System.String

[in] A string containing the path to the snippet template file.

Type: Microsoft.VisualStudio.TextManager.Interop.TextSpan

[in] A TextSpan object specifying the position where the snippet is to be inserted.

Type: System.Boolean

[in] This is true if there is more than one snippet with the given title and a dialog box must be shown so the user can select which snippet to insert; otherwise, this is false (accept the first snippet with the given title).

Return Value

Type: System.Boolean

If a snippet was inserted, returns true; otherwise, returns false.

This is a helper method that can be called from your own code, typically in association with the FindExpansionByShortcut method. See the example in the ViewFilter class to see how this method is used.

The base method calls the InsertNamedExpansion method on the IVsExpansion object. If InsertNamedExpansion succeeds, the ExpansionProvider class is put into the edit expansion mode and the base method returns true. Otherwise, the edit session is ended and the base method returns false.

Return to top