AI Assistant
Help Center AI Assistant is now available
Got questions about Lark? Use our AI chat to find the answers.
00:00
Click and hold to drag
Got It
Try Now
Insert code blocks in Docs

Insert code blocks in Docs

4 min read
Desktop
Mobile
more
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
What coding languages are supported by code blocks in Docs?
The following coding languages are supported by code blocks:
ABAP, Ada, Apache, Apex, Apache, Assembly language, BASH, C#, C++, C, COBOL, CSS, CoffeeScrip, D, Dart, Delphi, Django, Dockerfile, Erlang, Fortran, FoxPro, Gherkin, Go, Groovy, HTML, HTMLBars, HTTP, Haskell, JSON, Java, JavaScript, Julia, Kotlin, LaTeX, Lisp, Logo, Lua, MATLAB, Makefile, Markdown, Nginx, Objective-C, OpenEdgeABL, OpenGL Shading Language, PHP, Perl, PostScript, PowerShell, Prolog, ProtoBuf, Python, R, RPG, Ruby, Rust, SAS, SCSS, SQL, Scala, Scheme, Scratch, Shell, Swift, Thrift, TypeScript, VBScript, VisualBasic, XML, YAML.
Can I copy and paste codes to a code block in Docs?
Yes, and the language will be automatically identified and displayed in the upper-left corner.
If the content of a code block inserted in the document is too long, can it be displayed in a collapsed format?
No, this is not supported.
Written by: Lark Help Center
Updated on 2025-01-29
How satisfied are you with this content?
Thank you for your feedback!
Need more help? Please contact Support.
0
rangeDom
rangeDom
rangeDom
rangeDom