How to Send a Code Snippet in Microsoft Teams

Microsoft Teams is a collaboration platform that makes it easy to communicate with team members working on similar projects. From sharing your screen, to instant message like chatting, MS Teams offers a lot of useful features.

For software developers, a particularly useful feature is the ability to send snippets / blocks of code to members of your team. In this article, we’ll show you how to send a snippet of code in Microsoft Teams.

How to Send a Snippet of Code in Microsoft Teams

Step 1: From a chat window, click the Format button under the message box

Microsoft Teams Format Text Button

Step 2: Click the 3 dots in the upper right corner of the, now expanded, message box

Microsoft Teams Format Text More Options

Step 3: Select Code snippet

Microsoft Teams Insert Code Snippet

Step 4: In the new window, paste your code snippet then click Insert

You can also change syntax highlighting by using the language drop down in the upper right corner.

Microsoft Teams Insert Code Snippet Window
Microsoft Teams Code Snippet in Message Box

Share Code Snippets with Keyboard Shortcuts

While the method above is great for one-off code sharing, doing it often can become a bit tedious. Thankfully, Teams has some keyboard shortcuts to make sharing your code even easier.

  • To send an inline snippet of code, start and end the text with a single back tick (`).
  • To send a block of code, first preface the text with three back ticks (“`) then paste your block of code.

Check out Microsoft’s article on markdown formatting in Teams for other text formatting tips.

14 thoughts on “How to Send a Code Snippet in Microsoft Teams”

  1. Some keyboard layouts have ` as a dead key. This means I usually type 4 ` to produce them and then do one backspace. But that won’t produce the code block formatting area. Very inconvenient! 🙁

    It’s the same problem as the regular inline code formatter with backticks `code` have: You have type the left one FIRST and then do the right one followed by a space. Also inconvenient and very confusing since I for a long time though teams didn’t have code formatting at all!

    Please at least get on the same level at Discord. (L)

  2. Teams sucks. On a German keyboard I have to type 3 keys to get a single ` character, making this “shortcut” 9 keystrokes.
    Which is still better than the 10 mouse clicks (I didn’t count) to get the other solution, I guess. But still… SUCKS

    • You can press Shift+` 3 times (not 4) then press space. After that you can paste the code. This will work on german keyboards.

    • Check what special characters do the “AltGr” combinations produce. Try AltGr+H.
      Or you can use msklc.exe to produce your own keyboard layout (you can do it once and than instal your new layout whenever you want).


Leave a Comment