3 Ways to Insert Code in Medium Articles
PLUS a fresh NEW one!

Objective: learn how to put code snippets in a Medium article
I found myself extensively putting code snippets in my Medium articles. Well, it was not so unexpected since I majorly write about game developing, and more specifically I produce tutorials.
It came to my mind that a quick guide about this Medium feature could be very helpful for anyone writing about this topic.
Long story short: I use 3 types of code input.
In-line small snippet
This kind of snippet would appear like this or this:int a = 0; .
To put such a snippet a back-tick ` is necessary: the shortcut is ALT + 96 . Once the back-tick appears in the text editor, start writing code immediately after it.

Snippet block
If you need to put several lines of code, the block is what you may need. The block can be started by inserting 3 consecutive back-ticks ```. It will appear like this:
//Don't forget
//to put the 3 back-ticks ```
//in a new line or paragraph in Medium Editor
Using GitHub Gist feature
The last way is my favourite one. It will allow a little syntax highlighting, according to the language you choose. Moreover, the colours automatically adapt to the dark themes of the browser.
I’m talking about Gist, powered by GitHub. Of course, you need a GitHub account.

On the page, you will find a text box in which you can write or paste your code. The box also accepts TAB and SHIFT+TAB inputs to adjust indentation. You can set a description for your gist, and a name.

When you choose a name, don’t forget the extension! In this way, the language will be recognized and the highlighting will appear.

Now you can save it: choose whether it should be private or public, then save it.

Once the gist is created, you’ll land on a new page where you can edit or comment on it or, as I do, copy the link to it.


The link can now be pasted in your article.

But it will transform into a beautiful code snippet only when you put a newline after it:










