Google’s making code formatting a breeze in Docs

Originally posted on theverge.

Certain Workspace users will be getting access to code blocks, which could help them upgrade their documentation.

Google Docs is getting a new feature that will make it easier to show code in an easy-to-understand way. The company announced that it’s adding code blocks to its “smart canvas” system, which will automatically add the proper spacing and color-coding for a variety of programming languages, such as Python, C, and Javascript.

Before this, getting code to look nice in Google Docs required workarounds or add-ons, which weren’t necessarily the most convenient. While that wasn’t the end of the world, making sure code displays properly is important for documentation, and having different parts of the code display in different colors makes it much easier to read if there’s more than a single line or two.

Gif showing someone formatting a few lines of code using Google Docs’ code blocks.

Doesn’t that look so much nicer?
 GIF: Google

Google says you’ll be able to access the feature by going to Insert > Building Blocks > Code Block and then selecting the relevant language. You’ll also be able to type “@project assets” into your document to pull up the menu, similar to how you’d summon the emoji picker.

The feature may take a while to roll out — Google’s blog post says some people may not even have it by January 18th, depending on their Workspace’s settings — and it’ll only be available to people with specific subscription tiers. If you’re using a personal Google account, a legacy G Suite account, or various Essential and Starter Workspace tiers, you won’t have access to it, according to the company’s press release. That’s a bit of a bummer for hobbyist coders trying to write instructions for their APIs, though I’ll admit that this feature does seem like it’d be most useful for bigger companies.

Source: theverge