Join the AMA (Ask Me Anything) with the Firefox leadership team to celebrate Firefox 20th anniversary and discuss Firefox’s future on Mozilla Connect. Mark your calendar on Thursday, November 14, 18:00 - 20:00 UTC!

საიტის გასაუმჯობესებელი სამუშაოების მიმდინარეობისას, შესაძლებლობების ნაწილი შეიზღუდება. თუ სტატიით ვერ მოახერხებ ხარვეზის გამოსწორება და შეკითხვის დასმა გსურთ, ჩვენი მხარდაჭერის გუნდი დაგეხმარებათ @FirefoxSupport გვერდის მეშვეობით Twitter-ზე და /r/firefox განყოფილებაში Reddit-ზე.

ძიება მხარდაჭერაში

ნუ გაებმებით თაღლითების მახეში მხარდაჭერის საიტზე. აქ არასდროს მოგთხოვენ სატელეფონო ნომერზე დარეკვას, შეტყობინების გამოგზავნას ან პირადი მონაცემების გაზიარებას. გთხოვთ, გვაცნობოთ რამე საეჭვოს შემჩნევისას „დარღვევაზე მოხსენების“ მეშვეობით.

ვრცლად

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

  • 10 პასუხი
  • 1 მომხმარებელი წააწყდა მსგავს სიძნელეს
  • 1 ნახვა
  • ბოლოს გამოეხმაურა yeseanul

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)

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.

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?

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.

One more variant; the <pre> tag:

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

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).

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.

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.

შერჩეული გადაწყვეტა

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

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

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