Dmitri Nesteruk
Dmitri Nesteruk

Reputation: 23789

How to get Visual Studio editor text with color formatting?

I have a VS plug-in that currently takes the editor text by getting a TextDocument via app.ActiveDocument.Object() and then I get the text from that. This, however, is just plain text, and I'd like to have not just text but the color information (kind of like the RTF export). How can I get it?

Upvotes: 0

Views: 164

Answers (1)

Carlos Quintero
Carlos Quintero

Reputation: 4414

Cast EnvDTE.TextDocument.Selection to EnvDTE.TextSelection and then use EnvDTE.TextSelection.Move(point1, false) and EnvDTE.TextSelection.Move(point2, true) and then EnvDTE.TextSelection.Copy() to copy to the clipboard, which you should preserve saving its content before copying and then restoring when done.

Upvotes: 1

Related Questions