I. Intro
You can insert code blocks in documents to clearly and accurately display codes. Over 70 coding languages, from C to Java to Python, are supported, with syntax highlighting and line wrapping.
250px|700px|reset
II. Steps
Insert code blocks
Open the document and use one of the following methods to insert a blank code block:
Method 1: Enter /code block at the beginning of a blank line and select Code block.
250px|700px|reset
Method 2: Hover over a blank line and click the + icon on the left > the Code block icon.
250px|700px|reset
Method 3: On a blank line, press Ctrl + Alt + C (Windows) or Command + Option + C (Mac).
Method 4: On a blank line, enter ``` and press Space or Enter or ```[coding language] and press Space or Enter.
Convert content to code blocks
In the document, you can convert existing content into a code block using the following methods:
Method 1: Hover over the content, then click the ⋮⋮ icon > the Code block icon to convert the text into a code block.
250px|700px|reset
Method 2: Enter /code block at the beginning of the line with text, or press Space anywhere in the text, and enter /code block. Select Code block to convert the paragraph of text into a code block.
250px|700px|reset
250px|700px|reset
Switch coding languages
The current coding language is shown in the upper-left corner of the block. Click it to view, search, or switch coding languages.
250px|700px|reset
Turn on/off line wrap
Hover over the code block and click Wrap in the upper-right corner of the code block to turn on line wrapping. When the code is too long, the code will wrap within the code block.
To turn off line wrapping, click Cancel wrap in the upper-right corner of the code block. When the code is too long, a horizontal scrollbar will appear in the code block, which you can use to view the complete code.
250px|700px|reset
III. FAQs