views:

62

answers:

3

How can i put snippets of code, in word or open office?

i am putting xml and java, if it has good formatting, even maybe a small shade in back, its even better

+2  A: 

Try copy / pasting it in from your IDE: Visual Studio at least puts it on the clipboard as RTF including all formatting. You should then highlight the section and set it to 'language: neutral' though to clear all the red squigglies you'll get.

At the very least you'll be able to get one of the free Visual Studio versions and use that to format the XML; I think it even has some proto-Java formatting support too from back when they had J#. I wouldn't be surprised if the good Java IDEs did this too.

Rup
+1  A: 

IF you are using Netbeans, you can chose to download the

Special CopyPaste

Plugin. This basically allows you to copy pieces of code and it converts it into XML. Once that it is pasted into word, word converts the XML back into the text that you had on the IDE. Indentations, text size, font and colours are maintained.

npinti
Thx, it keeps a good look and feel
blueomega
+2  A: 
  1. (As Rup said above), copy paste from eclipse/Netbeans. The code IS copied as rich text
  2. You might as well create a "style" in MS Word. A style is a group of formatting, saved under a single name (eg. "Red style" can be "Font Arial, Color Red, Font size 12, bold) and apply this to the source code you copy pasted. Details here and here
Nivas