Sharing Long Blocks of Code

Why it's helpful

Trying to share code with multiple screenshots takes time.

In some cases, you might want Mr. Gordon to try out your code, which is not possible when sharing screenshots.

Making a code block in Notion is faster for you to author, and it makes it possible for Mr. Gordon to copy and then try out your code, if necessary.

Create a code block

To create a code block in Notion, just type /code at the start of a new block:

Screenshot 2023-09-21 at 8.21.53 AM.png|300

After doing so, you will see an empty code block:

Screenshot 2023-09-21 at 8.23.30 AM.png

Copy code into the block

You can copy code from the Playgrounds app by placing your mouse cursor in the code editor, pressing Command-A to select all of the code, and then Command-C to copy it.

Switch to the code block in Notion, and then press Command-V to paste the code:

Screenshot 2023-09-21 at 8.25.14 AM.png

Select the correct language

Notion tries to apply syntax highlighting to the code – colour is used to make code more readable.

The code we are writing is in the Swift programming language.

Use the dropdown at the top-left corner of the code block to select Swift as the language:

Screenshot 2023-09-21 at 8.25.28 AM.png|350

There are many language options, so you can use search to make this a faster process.