I use Google Drive Docs as my note taking tool and it is awesome since I can use it when I am offline, but I have a problem: I can't add source code in documents there. I know this question is answered How can I get code syntax highlighting in Google Docs?, but Google documents have changed a lot and the solution given there is not working properly.

Can anybody suggest a suitable way for it?

  • Do you need it to be styled? – Jacob Jan Tuinstra Dec 24 '12 at 18:11
  • That linked answer just says that you need to paste a formatted code and then change the font. It still works. If you need colored codes, then you can copy paste the code from, say, Github or some other site where the code is presented as color-coded. – Bibhas Dec 25 '12 at 22:13
  • Have a look at this answer: webapps.stackexchange.com/a/37830/29140. Perhaps it is of use: – Jacob Jan Tuinstra Jan 27 '13 at 11:18

There's now an add-on for Google Documents called Code Pretty, which does code formatting for you.

| improve this answer | |

Convert your source code to HTML using a text editor such as Vim or Emacs, and then paste the resulting HTML into your Google Drive.

This method has the added benefit of being available while offline, which -- from your question -- also seems to be important to you.

In Vim, use the ":TOhtml" command. (In gVim, use "Convert to HTML", on the Syntax menu.)

In Emacs, use htmlize.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.