Word – Why does code pasted from Visual Studio to Word and from Word to Gmail keep colors

colorsmicrosoft wordstylesvisual studio 2010

Why, if I copy code from Visual Studio directly into Gmail, all styles are removed but if copied first to Word and then from Word into Gmail then all styles including fonts and color are kept?

Best Answer

Gmail is aware of Word styles. Any styling on text copied from Word is pasted from the clipboard as either Word HTML or RTF if the destination application supports those formats (which Gmail's editor does). Visual Studio's styling isn't copied to the clipboard as Word HTML or RTF, so Gmail's editor will ignore the VS styling. However, Word is aware of VS styling and apparently can convert that styling to Word HTML or RTF when text is copied from VS to Word, copied from Word, then pasted to Gmail.

The best way I know to remove styling from any text is to paste whatever text you want to be plain into notepad, select it, copy it, and paste it again in your final destination.

Related Question