简体   繁体   中英

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

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

When I copy from Eclipse straight to PowerPoint some of the formatting is messed up. Bold and color seems to "keep going". But if I copy from Eclipse to Word -- and then from Word to PowerPoint (with the keep source formatting CNTRL-K) -- the formatting is correct. I recently upgraded Eclipse to Mars and Office to 2013. I still have to go through Word first.

I was trying it too and for some reason not every compile unit would keep the formating.

After a while I've seen that you also won't get the formating kept if there are parts of the code hidden, so for the ones that cannot make it work with the answers above, just make sure that there are no "+" signs on the left of your code (mine were where the imports at the beggining).

Copying of formatting is supported since version 3.2

Note that everything is copied: highlighting of spelling errors, marked variables/types/etc and underscoring of warnings/errors.

To avoid that, turn off spell checking, "Mark Occurrences" and "Report problems as you type" respectively.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM