Is there a easy way to insert source code with highlight in Google Docs?
-
Well, this question is not really a duplicate. The related question asks explicitly for Syntax Highlighting. This question is more generic. And the answer is: Currently this is not possible. You can use plugins which set colors for you, but inside the document this is just text with color, not "code" (pre). This becomes especially relevant, when handling with the document structure in the docs API.– ArminJul 27, 2021 at 15:48
-
This question doesn't meet the current quality standards. Nowadays this might be a trivial question.– Rubén ♦Apr 7 at 19:00
2 Answers
Not directly but there is an easy way to do it.
You can use the online Colorer-take5 HTML generator to produce the highlighted code. Afterwards just copy/paste it into your document, but don't forget to change the font to Courier New
and probably reducing the size of it and you're done.
Here is an example for Java code and using the Eclipse style:
-
8Great idea, but I would suggest pygments.org to generate colored HTML (with multiple styles) and Consolas as font.– schlamarDec 12, 2012 at 21:33
-
I used Microsoft word for this. Pasted my code in Microsoft word and then copy/paste in google docs– gogagubiJun 15, 2019 at 12:19
With the new Add-Ons for Google Drive, you can get code highlighting with the Code Pretty add-on.
After installing it, you can access the add-on by clicking Add-ons → Code Pretty, → Format Selection:
This results in:
-
4
-
3
-
-
1@IgorVaschuk, for me it does (for instance, I use PyCharm with the Darkula theme). I just need to cancel the highlighting in the google doc. Oct 17, 2016 at 21:21
-
1