To send a code snippet in a chat or channel message, first click Format below the compose box, then select Code snippet in the format bar. This opens a dialog box, where you can enter your code as well as a title for the snippet. Select the language you want to use, and choose whether you want your text to wrap.
Syntax highlighting and auto-indentation help you to 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.
If you want to edit your code snippet after you’ve sent it, select More options > Edit on your message, then Edit again on the snippet card.