Share via

Cannot copy and paste new lines of a multi-line code block

Anonymous
2023-02-14T06:31:02+00:00

New lines are removed from the content of a copied multi-line code block.

For example, if someone sent the below as multi-line code block:


    Line 1
      Line 2 with 2 spaces

    Line 3

Then another person copied the rendered message, the result would be:


    Line 1  Line 2 with 2 spacesLine 3

Microsoft Teams | Microsoft Teams for business | Chats | Group chats

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

28 answers

Sort by: Most helpful
  1. Anonymous
    2023-04-06T20:35:56+00:00

    Here's an oddity we've found when testing this. If you not only select the text IN the snippet window (line numbered text), but you also select the row above the box containing the data type lable (SQL, TEXT etc)... you keep your line breaks from the box. If you don't select that top line, you get the code snippet text all mashed together with no line breaks or tabs.

    60+ people found this answer helpful.
    0 comments No comments
  2. Anonymous
    2023-02-14T22:18:21+00:00

    > This is likely happening because the formatting and spacing of the code block are lost when copied and pasted from Teams.

    I think this is the crux of the problem and should be resolved. Having to work around it is not a suitable solution. Especially if that involves responding to ask the sender to re-send in a different format. That's just embarrassing.

    30+ people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2023-03-23T14:55:46+00:00

    This is likely happening because the formatting and spacing of the code block are lost when copied and pasted from Teams.

    Exactly.

    The best way to reply back to the customer is to ask them to re-send their message as a multi-line code block. This will ensure that the formatting of the code remains intact and will make it easier to read.

    Due to the above issue, this isn't possible.

    Create a 'code snippet' and enter some text on a few separate lines

    Now, from the chat window, copy that text into an editor.

    Observe everything on one line.

    This is a bug surely?

    30+ people found this answer helpful.
    0 comments No comments
  4. Anonymous
    2023-03-23T15:14:10+00:00

    I've noticed that this doesn't happen to code snippets in a 'channel' but does when in a personal/group message.

    8 people found this answer helpful.
    0 comments No comments
  5. Anonymous
    2023-04-25T14:29:27+00:00

    This doesn't appear to work for me. It technically keeps the original line returns but then also introduces additional breaks.

    So if it should look like this:

    Line1

    Line2
    

    Line 3

    It will look like this:

    Line1

    Line2

    Line3

    This is problematic with long blocks of code.

    6 people found this answer helpful.
    0 comments No comments