Αυτός ο ιστότοπος θα έχει περιορισμένη λειτουργικότητα, όσο εκτελούμε εργασίες συντήρησης για να βελτιώσουμε την εμπειρία σας. Αν ένα άρθρο δεν επιλύει το ζήτημά σας και θέλετε να κάνετε μια ερώτηση, η κοινότητα υποστήριξής μας είναι έτοιμη να σας βοηθήσει στο Twitter (@FirefoxSupport) και στο Reddit (/r/firefox).

Αναζήτηση στην υποστήριξη

Προσοχή στις απάτες! Δεν θα σας ζητήσουμε ποτέ να καλέσετε ή να στείλετε μήνυμα σε κάποιον αριθμό τηλεφώνου ή να μοιραστείτε προσωπικά δεδομένα. Αναφέρετε τυχόν ύποπτη δραστηριότητα μέσω της επιλογής «Αναφορά κατάχρησης».

Μάθετε περισσότερα

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

  • 10 απαντήσεις
  • 1 έχει αυτό το πρόβλημα
  • 217 προβολές
  • Τελευταία απάντηση από 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

Επιλεγμένη λύση

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

Ανάγνωση απάντησης σε πλαίσιο 👍 1

Όλες οι απαντήσεις (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

Επιλεγμένη λύση

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.

Τροποποιήθηκε στις από τον/την yeseanul

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