Pasting Code.

When you paste code into a reply it doesn't get formatted correctly, which makes it difficult to read.

Is there any way to mark code in the message input text box so that when its displayed its correctly formatted ? Could a feature like that be added ?

[267 byte] By [DerekSmyth] at [2007-12-18]
# 1

Could you paste an example code peice that gives you problems? What are you copying from? VS?

JoshLedgard at 2007-9-8 > top of Msdn Tech,Feedback for forums and MSDN websites,Bug Reports for Forums website...
# 2

Josh,

Here is an example:

using System;

using System.Collections.Generic;

using System.Text;

namespace Namespace

{

public class Class1

{

private string _Value;

public string Array

{

get { return _Value; }

set { _Value = value; }

}

}

}

This was pasted directly from VS2005. You can see that the spaces were removed and every line is double-spaced.

DavidM.Kean-MSFT at 2007-9-8 > top of Msdn Tech,Feedback for forums and MSDN websites,Bug Reports for Forums website...
# 3

Yup, It's a bit annoying having to go in afterwards and switch it to single space. I'd also like to see code paste as a fixed with font (Courier New) for example. So, instead of:

Private Sub DrawControl(ByVal g As Graphics)

g.Clear(Color.Black)

T.Start()

g.TranslateTransform(0, Me.ClientSize.Height \ 2)

g.ScaleTransform(0.5, -1)

g.DrawLines(m_Pen, m_Points)

T.Stop()

'

g.ResetTransform()

Call DrawInterval(g, T.Duration)

Me.Invalidate()

End Sub

We would have:

Private Sub DrawControl(ByVal g As Graphics)
g.Clear(Color.Black)
T.Start()
g.TranslateTransform(0,
Me.ClientSize.Height \ 2)
g.ScaleTransform(0.5, -1)
g.DrawLines(m_Pen, m_Points)
T.Stop()
'
g.ResetTransform()
Call DrawInterval(g, T.Duration)
Me.Invalidate()
End Sub

But maybe that's just me...

SJWhiteley at 2007-9-8 > top of Msdn Tech,Feedback for forums and MSDN websites,Bug Reports for Forums website...
# 4

This has been reported to the forums team as a bug...the same problem exists when copying and pasting from Word.

Joe

JoeMorel-MSFT at 2007-9-8 > top of Msdn Tech,Feedback for forums and MSDN websites,Bug Reports for Forums website...
# 5

A quick work-around, less the coloured keywords:

  1. Change to HTML view
  2. type <pre></pre>, and paste your (formatted with indents) code inbetween the tags
  3. Change back to GUI view and add comments around the inserted code

Personally, I find indentation more useful than coloured keywords, but that's just personal preference. It'd be nice to have both.

# 6
The double-spacing after carriage returns was previously caused by the

default use of <P> markers in the rich-edit text-box. The default

behaviour has now been changed to insert <BR> marks instead, so

all pastings should now only be one carriage-return per line, rather

than two. Great!

# 7
It's too bad that the default CSS attributes for PRE make the text-size so small as to be unreadable. I really would like to see a Code option in the Paragraph style drop-down list.
JohnSudds-MSFT at 2007-9-8 > top of Msdn Tech,Feedback for forums and MSDN websites,Bug Reports for Forums website...