Syntax Highlighting on Slack

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

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 is part of our Slack mini series, where we quickly explain simple and more advanced Slack features. Excellent for beginners or if you just need a quick refresher.

If there is a feature you would like us to cover please drop us an email or tweet.

Recent posts View all

Ruby

What are the square brackets in my Rails migrations?

Let's look at what these little square brackets are doing in our Rails migration files

Web Dev

Setting a minimum TLS version with CloudFlare

How to set a minimum TLS version on CloudFlare and why you should consider it