Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pasting source code in word 2007

If i try to paste source code in word 2007 the spacing between the lines seems to get messed up as all new lines are spaced way apart compared to a programming text editor.

Can somebody tell me how to paste source code in word 2007 preserving the formatting and the spacing between lines?

like image 875
pdeva Avatar asked Nov 11 '08 04:11

pdeva


3 Answers

Try your IDE's (or editor's) "Export to Clipboard as HTML" or "Export to clipboard as RTF" function. Then paste in Word. Guess it should work. It works on Outlook (it even preserves the syntax coloring)

like image 110
RuntimeException Avatar answered Oct 18 '22 12:10

RuntimeException


The problem is that each line is a paragraph, and often in Word, paragraphs have a certain amount of Space Before. If you choose a style that has 0 space before, and 0 space after, it should look fine.

like image 43
Ned Batchelder Avatar answered Oct 18 '22 13:10

Ned Batchelder


As already mentioned, it's because of the paragraph spacing. Either chose a style with no spacing, or select the text and format paragraph and set the before and after spacing to 0. This was easy with earlier versions, but is presumably complicated now we have ribbon controls. :)

like image 22
Richard A Avatar answered Oct 18 '22 14:10

Richard A