Eclipse copy code with syntax highlighting

Alessandro Pezzato picture Alessandro Pezzato · Dec 5, 2011 · Viewed 18.4k times · Source

I'm writing a document of programming guidelines for my developers team. I use MS Word. We work with Eclipse CDT (C++). I need to copy-paste C++ code with syntax highlighting from Eclipse to Word. I've tried Notepad++ and it can export text with syntax highlighting, but it's highlighting is limited to basic syntax (it doesn't know about defined class, enum etc...). Eclipse syntax highlighting is very powerful and I wish to export directly from Eclipse to Word using it's syntax highlighting.

Is there any Eclipse plugin that achieve this purpose? Or some trick to do it (without taking a screen snapshot)?

Answer

Mansuro picture Mansuro · Dec 5, 2011

When you copy the code to word document, you can choose the option "keep source formatting" and the highlighting will be the same as the one in eclipse.

EDIT:

As mentioned in the comments below, this won't work on folded code, so you can right click on the line numbers and select Folding > Expand All

EDIT 2: Also mentioned in the comments, as of eclipse oxygen, the code is automatically copied with syntax highlighting