Cerca nel supporto

Attenzione alle mail truffa. Mozilla non chiederà mai di chiamare o mandare messaggi a un numero di telefono o di inviare dati personali. Segnalare qualsiasi attività sospetta utilizzando l'opzione “Segnala abuso”.

Ulteriori informazioni

Questa discussione è archiviata. Inserire una nuova richiesta se occorre aiuto.

How to retain formatting while pasting code from Visual Studio into Thunderbird?

  • 10 risposte
  • 1 ha questo problema
  • 1 visualizzazione
  • Ultima risposta di yeseanul

more options

Hello,

Oftentimes I'm copy/pasting code snippets from Visual Studio into Thunderbird. Problem is that doing this directly does not preserve the formatting.

Workaround 1 - works great but it's slow (a lot of copy/pasting) Copy from Visual Studio. Paste into MS Word. Copy from MS Word. Paste into Thunderbird.

Workaround 2 - fast but the result is not so nice (in terms of formatting C# code) Use "pasteCode" Add-on.

Is there a better way?

Thanks for any suggestion, -Alex

Hello, Oftentimes I'm copy/pasting code snippets from Visual Studio into Thunderbird. Problem is that doing this directly does not preserve the formatting. Workaround 1 - works great but it's slow (a lot of copy/pasting) Copy from Visual Studio. Paste into MS Word. Copy from MS Word. Paste into Thunderbird. Workaround 2 - fast but the result is not so nice (in terms of formatting C# code) Use "pasteCode" Add-on. Is there a better way? Thanks for any suggestion, -Alex

Soluzione scelta

Actually, Microsoft's "Productivity Power Tools" extensions add HTML to the clipboard automatically when you copy:

Blog post with more information from an earlier version: http://blogs.msdn.com/b/kirillosenkov/archive/2010/06/07/copy-code-in-html-format-with-visual-studio-2010.aspx

Leggere questa risposta nel contesto 👍 1

Tutte le risposte (10)

more options

Are you using plain text? That's more likely to work verbatim, except that like most email, it is in danger of being line-wrapped.

Have you tried the <preformat>…</preformat> tag pair? It is, IIRC, supposed to protect the enclosed material.

more options

Zenos said

Are you using plain text? That's more likely to work verbatim, except that like most email, it is in danger of being line-wrapped. Have you tried the <preformat>…</preformat> tag pair? It is, IIRC, supposed to protect the enclosed material.

I'm using "Compose messages in HTML format". I'm not familiar with using the "preformat" tag pair. Can you please elaborate?

more options

I'd been tinkering with some hand-edited HTML code and I was rather stuck in that mode of thought.

In the html composition window, there's a style button which drops down a list of pre-set styles. Body Text or Paragraph seem to be the default. One labelled "Preformat" (strange name!) should preserve your code indents and whatnot. In my system, it seems that it also switched to my fixed-pitch font, again in the interests of preserving indents.

Here on this forum we have a <code> tag which does much the same, though here we also have the much simpler tool of just inserting a leading space.

So, I'd expect the default to mess things up (particularly on a very long line of code):

if (hours < 24 && minutes < 60 && seconds < 60 && hours < 24 && minutes < 60 && seconds < 60) {

   return true;

} else {

   return false;

}

(note the wobbling between proportional and fixed width fonts)

The code tag gets us: if (hours < 24 && minutes < 60 && seconds < 60 && hours < 24 && minutes < 60 && seconds < 60) {

   return true;

} else {

   return false;

} and I must say I am disappointed by the line spacing and the way it has wrapped the line. However, I suspect that the wrapping is largely cosmetic and indeed, when pasted into a text editor, it shows as a soft wrap, not a hard linefeed.

And finally, the leading space thing does this:

if (hours < 24 && minutes < 60 && seconds < 60 && hours < 24 && minutes < 60 && seconds < 60) {
    return true;
} else {
    return false;
} 

but of course that is specific to this forum's software. I don't expect it to work in Thunderbird. :-(

The tag is probably the cleanest if you want to copy and paste your code from the received message.

The preformat style in Thunderbird is essentially a <code> tag.

more options

One more variant; the <pre> tag:

if (hours < 24 && minutes < 60 && seconds < 60 && hours < 24 && minutes < 60 && seconds < 60) {
    return true;
} else {
    return false;
} 
more options

I've tried the Preformat, and the result isn't the desired one. I've uploaded an image in order to show the differences between multiple options and pointed out the desired outcome (which is attainable right now only by using a 3rd party app, and additional steps).

more options

Have you tried pasting as a quote? (Ctrl+Shift+O) that forces the preformat tags among a couple of other things

Just as a side note... You say you are not using the compose in HTML option, but plain text does not support coloured text, so you are using HTML.

I have not checked, but it would be my guess that Visual studio only places RTF and text on the clipboard so your direct paste places the text as the only compatible format. Word gets the RTF as it takes that by default over plain text.

Finally word actually places HTML on the clipboard as well as text and RTF and BIff if I recall correctly so you see formatted text in your email when pasting from Word.

You should really have a look at the HTML source that you paste, as word includes the entire content of the normal.dot file with each paste, your mail will be huge relative to the visible content and may well contain private information you would prefer not to share. Your computer user name being one item I have observed. Hacking is easier if you have the user name as a starting point.

more options

What do you think about trying a Visual Studio add-on? This one sounds like it's in the ballpark: Copy As HTML extension | MSDN.

more options

Soluzione scelta

Actually, Microsoft's "Productivity Power Tools" extensions add HTML to the clipboard automatically when you copy:

Blog post with more information from an earlier version: http://blogs.msdn.com/b/kirillosenkov/archive/2010/06/07/copy-code-in-html-format-with-visual-studio-2010.aspx

more options

Matt said

Have you tried pasting as a quote? (Ctrl+Shift+O) that forces the preformat tags among a couple of other things Just as a side note... You say you are not using the compose in HTML option, but plain text does not support coloured text, so you are using HTML. I have not checked, but it would be my guess that Visual studio only places RTF and text on the clipboard so your direct paste places the text as the only compatible format. Word gets the RTF as it takes that by default over plain text. Finally word actually places HTML on the clipboard as well as text and RTF and BIff if I recall correctly so you see formatted text in your email when pasting from Word. You should really have a look at the HTML source that you paste, as word includes the entire content of the normal.dot file with each paste, your mail will be huge relative to the visible content and may well contain private information you would prefer not to share. Your computer user name being one item I have observed. Hacking is easier if you have the user name as a starting point.

I am using HTML. "Paste As Quotation" doesn't work. Your comments regarding HTML, Visual Studio and Copy/Pasting I think are very pertinent.

Modificato da yeseanul il

more options

jscher2000 said

What do you think about trying a Visual Studio add-on? This one sounds like it's in the ballpark: Copy As HTML extension | MSDN.

This should do the trick. Thanks