13

When I paste text from Eclipse into Word, it puts each line on its own paragraph. Manually correcting these to line-breaks (shift+enter) is a hassle, is it possible to automate this?

I'm using Word 2008 for Mac if that makes a difference (but would like to know this for other versions of Word too if they differ).

3 Answers 3

19

http://support.microsoft.com/kb/214204

You can use the special characters listed in the "More Information" section of this article with the Find and Replace commands on the Edit menu.

You want to replace ^p with ^l (typed literally - the ^ character does not indicate CTRL in this instance), and wildcards must be off for this to work.

To search and replace in just a selection of text rather than the entire document, select the text, bring up the search and replace dialog, and ensure "Current document down" is selected. Now when you click "replace all" it will only search inside the selected text and will prompt you before performing replacements on the rest of the document.

0
1

Copy a paragraph break and paste in the find textbox. Copy a line break and past in the replace textbox. Click on replace all.

1
  • 1
    Copy pasting this special character does not work in Word 2013. Commented Mar 18, 2014 at 15:31
0

Alternatively, you might just define a style with no paragraph spacing (and a monospaced font) to use for code.

1
  • 1
    I did this, but Word works a lot better if you work with it rather than fight it. With the code as a single paragraph I only need to set the style on any point for it all to be covered, I can more easily keep code blocks on one page, and I can use tricks like automatically changing to the "Normal" style if I carriage return at the end of a code block.
    – ZoFreX
    Commented Aug 11, 2011 at 16:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .