Skip to content

Instantly share code, notes, and snippets.

@ioncodes
Created July 28, 2016 09:39
Show Gist options
  • Save ioncodes/e5b98b3916de7a5c814cf6bc595f9dfe to your computer and use it in GitHub Desktop.
Save ioncodes/e5b98b3916de7a5c814cf6bc595f9dfe to your computer and use it in GitHub Desktop.
Shows how to get the text from the active document via DTE
private DTE _dte;
private NAME(Package package)
{
// ...
_dte = (DTE) ServiceProvider.GetService(typeof(DTE));
// ...
}
private static string GetDocumentText(Document document)
{
var textDocument = (TextDocument) document.Object("TextDocument");
EditPoint editPoint = textDocument.StartPoint.CreateEditPoint();
var content = editPoint.GetText(textDocument.EndPoint);
return content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment