Google Docs is one of the most popular ways to create and share text documents, but up until now, sharing code samples has been a bit cumbersome. That's finally changing.

Google said in a blog post today, "currently, when working in Google Docs, collaborators who want to present code have to paste it in the document and then manually apply styles by highlighting syntax. We're adding a new smart canvas feature that makes this process much easier by enabling you to format and display code in Docs with code blocks."

There's a new option to insert a code block rolling out, accessible from Insert > Building blocks > Code block. From there, you can pick from a few different programming languages, such as Java, Python, C++, and JavaScript. Google Docs will then create a block and provide the correct color formatting for the selected language. You can also just type the @ symbol in a document, then "code blocks."

The new code blocks should come in handy for anyone working on programming tutorials, code project examples, or anything else in Google Docs that might need to include code samples.

Google says the feature should roll out within the next 15 days, but it's not available to personal Google accounts (e.g. Gmail logins) yet, only Workspace accounts provided by a company or other organization. It's not clear when, or if, everyone will be able to try it.

Source: Google Workspace Updates