0

I'm trying to collect thousands of code lines from the programming tool to Microsoft Office Word 2010 to prepare a book, but when copying the code to Word, it looks horrible. The semi-columns and brackets are in the wrong places; it looks like this:

1

It's hard to write the whole code manually again. Any help??

7
  • What program are you copying the text from? Which word paste command are you using? Are you using a monospace font?
    – PatKilg
    Jul 11, 2013 at 12:54
  • the program I'm copying from is multisim(mentor graphics) which for vhdl code the word paste command is Ctrl+C I'm not using monospace font
    – Salahuddin
    Jul 11, 2013 at 13:09
  • Just real quick for me, try using the paste+text only command. If that doesn't work, see nsr81's answer on line endings, it sounds like that's really your problem.
    – PatKilg
    Jul 11, 2013 at 13:25
  • the problem is not that two lines appear in the same line, but you may find the semi-column at the begging of the line with strange shape, you may find the begging bracket at the begging followed by the end bracket directly..
    – Salahuddin
    Jul 11, 2013 at 13:29
  • 1
    Also try not copying directly from the program. For example (I do not use multisim so apologies if these features do not exist) "save as" the source code in a .txt format, then copy it into word from notepad rather than multisim. Or use notepad as an intermediary to remove formatting (I do this all the time). Basically copy paste it into notepad first, then copy paste from notepad into word. If it copy pastes into notepad funny then let us know because that is helpful information (still thinking line endings though...)
    – PatKilg
    Jul 11, 2013 at 13:31

2 Answers 2

3

Notepad++ has a plugin called NppExport. It allows you to copy RTF formatted text. The RTF formatted text will have syntax highlighting and proper indenting when you paste it into Word, as it appears in Notepad++.

To use the NppExport:

  1. Select the text to be copied
  2. In the menu, select [Plugins, NppExport, Copy all formats to clipboard]
  3. Paste the text into Word
0
3

If Word is screwing up your line endings, e.g. multiple lines of code show as one continuous line, your code might be using unix/linux line endings (\n character). You can try converting those to windows line endings (\r\n). Most text editors, like Notepad++/Ultraedit, will do it for you.

You can also do it online.

Also, you will need to use a proper font for styling your code, could be Courier or Consolas.

You must log in to answer this question.

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