To send a code snippet in a chat or channel message:

  1. In the message box, select Format Expand button.

  2. Choose Code snippet Code snippet button to reveal the space to place your code snippet.

  3. Add your code and create a title for the snippet. Select the option next to Wrap text if you want your text to wrap. Then, select the drop down to choose your programming language.

  4. Select Cancel or Insert to add the snippet to your message.Screenshot showing expanded code snippet box

Syntax highlighting and auto-indentation help you write your code the way you want. When you send your snippet, it’s included in the message as a card, and the recipient can view it inline with the syntax highlighting intact.

Tip: Use your keyboard to add a code block by typing /code in the compose box then press Enter. See Use commands in Microsoft Teams for more keyboard shortcuts. 

To edit your code snippet after you’ve sent it, select More options More options button > Edit Edit button on your message, then Edit Edit button again on the snippet card.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.