10

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?

3
  • Do you need it to be styled? Dec 24, 2012 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, 2012 at 22:13
  • Have a look at this answer: webapps.stackexchange.com/a/37830/29140. Perhaps it is of use: Jan 27, 2013 at 11:18

2 Answers 2

5

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

1

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.

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