Code snippet formatting in Teams

Vincent Le Bourlot 21 Reputation points
2022-05-23T13:41:35.223+00:00

Hi,

I've been redirected here from there: https://answers.microsoft.com/en-us/msteams/forum/all/code-snippet-formatting-in-teams/5f03cc1b-f90a-41e9-b31d-1307cc4be7ee?messageId=da79309d-72e4-4762-bbca-a84cb56706f7

After looking for a while, I found the
<space> shortcut to insert a code snippet, as the only option for that. I still can't find any way to format the code according to different languages such as yaml, cpp, json, etc. Is there any way to get syntax highlighting in code snippets in Teams?

Cheers

Vincent
Microsoft Teams Microsoft Teams for business Other
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 60,161 Reputation points
    2022-05-23T14:41:39.043+00:00

    Syntax highlighting is a client side feature. All existing syntax highlighting tools outside custom implementations (like Visual Studio) use JS libraries that reformat your existing HTML code block with CSS classes.

    AFAIK the code snippet in markdown doesn't support highlighting and only the devs could add that support. You should provide them feedback to request it. I believe there used to be a request for this but it is gone now. You can use the code editor block to get syntax highlighting though (Format option at bottom of message and then code snippet option). You'd use that in lieu of markdown.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Vincent Le Bourlot 21 Reputation points
    2022-05-23T14:46:52.58+00:00

    Thank you for your answer, however, that code editor is nowhere to be found... Am I missing something?

    I'm on macOS with Microsoft Teams Version 1.5.00.11157. It was last updated on 10/05/2022.

    204772-image.png


  2. Michael Hubbard 1 Reputation point
    2022-07-30T05:44:56.11+00:00

    I'm on an M1 Mac running Monterey, the same version of Teams and I have the code snippet. I mostly use Linux and it works there also.

    226268-image.png

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.