Syntax Highlighting on Slack

How to do syntax highlighting on Slack. Part of our Slack mini series

← Previous Slack article Next Slack article →

I’ve previously written before about simple formatting on Slack but what if you want to add syntax highlighting?

Say you want to share a block of Ruby code with a colleague and a simple code block just won’t cut it?

Here is how you can add a text snippet with syntax highlighting:

  • Start typing /snippet
  • From the “create a text snippet” screen, add your text
  • Select the language you want to use for syntax highlighting
  • Press “create snippet”

The old solution

If you’re somehow still on a very old version of their cient, this might still work. It worked for us when we wrote this article back in 2017!

If you click on the + symbol at the side of the text entry box, you will see an option for Code or text snippet, click on this. A pop out will appear. You can paste or type your code block into the large text input box. Then if you click on the drop down in the top right corner, you can select the language you’d like to format to. It has many popular languages such as C#, JavaScript, and HTML. It also has a text wrap option. From this view you can choose which room you’d like to share the code snippet.

This article is Part 9 in a 12 Part Series


Recent posts View all

Web Dev

Creating Docker images with M1 Macs

I ran into an issue with my Dockerfile when using it on a Linux machine, setting a platform fixed the issue

Web Dev

What does --no-owner mean in Postgres?

You have read a guide to doing Postgres exports or imports and seen --no-owner, this is what it means