Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse copy code with syntax highlighting

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)?

like image 379
Alessandro Pezzato Avatar asked Dec 05 '11 13:12

Alessandro Pezzato


People also ask

How do I copy code with syntax highlighting?

Select the portion of code you'd like to copy, then go the Edit menu and select Copy Special -> Copy as RTF. Your code, complete with syntax highlighting colors, is now stored on the clipboard. Simply press Ctrl + V in your other application to paste the code with syntax highlighting. It's that simple!

How do I paste code into eclipse?

You can toggle this behavior with the Toggle Quick Paste Cycles Through History command which is bound to CTRL+Shift+V on Windows and Linux and Command+Shift+V on Mac. You can paste from the history using the key binding CTRL+Shift+ALT+V on Windows and Linux and Command+Shift+OPTION+V on Mac.

How do I copy and paste from Eclipse to Word?

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. Show activity on this post. Show activity on this post. Show activity on this post.


1 Answers

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

like image 56
Mansuro Avatar answered Sep 18 '22 06:09

Mansuro