There might be times when you have to share part of your code or full code on google docs. Generally when you simple paste the code in google docs file it doesn’t look much readable as a code block. To make it more readable like it does in code editor you must use Code Blocks by Alex Forsythe.
Open Code Blocks install page and click install. After that open a new or existing document.
Click on Add-ons > Code Blocks > Start
This will open a dialogue box on the right side.
Now select the code which you want to format and click on preview in Code Blocks window.
This will show you how your code gonna look using Code Blocks. Now click on Format and you code on your document will be formatted properly.
So this is how you must format your code in google docs. Without using Code Blocks your code won’t look much pleasing and readable.