Google Docs, the popular word processing and spreadsheet application, has added code blocks to its interface, but not everyone is happy about it. Code blocks are a new way of writing code that allows for more concise and organized code. However, some users feel that they take away from the readability of documents. Code blocks are available in the editor for both text and code files. They can be inserted by pressing Ctrl+K (or Cmd+K on Mac) and selecting “Code Block.” Once inserted, you can type your code in the editor window or use the included keyboard shortcuts. Code blocks are great for organizing your code, but they can also be difficult to read if you’re not used to them. They’re best used when you have a lot of small pieces of code that need to be grouped together. If you just need to write a few lines of code, it’s better to just use regular text instead. ..
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