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)?
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!
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With