Send code snippets in a message in Microsoft Teams
To send a code snippet in a chat or channel message:
-
In the message box, select Format
. -
Choose Code snippet
to reveal the space to place your code snippet. -
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.
-
Select Cancel or Insert to add the snippet to your message.
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