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
Step 2: Click the 3 dots
in the upper right corner of the, now expanded, message box
Step 3: Select 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.
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.
They *** removed the triple backtick shortcut recently. *** hate the program manager who approved this, with passion.
No, you have to press extra space after back ticks now 😀
don’t get it.. tried and still not working
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)
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).
useless cant copy from chat
Is there any faster way? Any tags? Any chat command line options?
Hi,
Thanks for commenting! I found that there are 2 keyboard shortcuts related to sending code snippets.
```
for a multi-line code block`[code snippet]`
for an inline block of codeI’ve updated the article with this information also. It doesn’t seem to do any syntax highlighting when done this way though…
https://support.microsoft.com/en-ie/office/use-markdown-formatting-in-teams-4d10bd65-55e2-4b2d-a1f3-2bebdcd2c772
Thanks for this guide, do you know if its possible to make the code snippet colorized when doing the shortcuts?
Unfortunately the shortcuts don’t seem to do syntax highlighting.
I believe “` is actually the shortcut for a “quote”, and not a code snippet.
This is why it does not have syntax highlighting.
Microsoft begs to differ: https://support.microsoft.com/en-us/office/use-markdown-formatting-in-teams-4d10bd65-55e2-4b2d-a1f3-2bebdcd2c772