Copy Formatting Code to MS Word with Line Numbers

I have to write a book that includes some code snippet from my project in Eclipse. So, I need to copy code from Eclipse to MS Word with the same color format and line numbers. I use Notepad++ to help. This is the way I do it.

Setup new color scheme for Notepad++

1. Find the color scheme for notepad++. In this case is Eclipse color scheme (right click and save link as.. , save as filename “Eclipse.xml” and type “All Files”)

2. Download and move it to Notpad++ themes folder.

3. Restart Notepad++.

4. Go to “Settings” > “Style Configurator”. Select new theme and “Save”.

Make shortcut key to copy all text format

1. Go to “Settings” > “Shortcut Mapper”, select tab “Plugin commands”

2. Find the name “Copy all formats to clipboard”

3. Modify the shortcut to “Ctrl + Shift + C”

4. “OK” and “close”, now I use “Ctrl + C” to copy raw text and “Ctrl + Shift + C” to copy formatted text.

Insert line numbers

1. Copy code from Eclipse and paste to Notepad++

2. “Select All” and click “Edit” > “Column Editor” or press “Alt + C”

3. Choose “Number to Insert”, fill “initial number” and “increse by”.

4. “OK”, now it ready to copy to MS Word.

Copy and paste code to MS Word

1. “Select All” and press “Ctrl + Shift + C”

2. In MS Word, Go to “Insert” > “Object” and choose object type to “OpenDocument Text”

3. It will open new page, paste the code to that and save

4. Done. I get my code from Eclipse to MS Word with color and line numbers and also separete it from the rest by use object to wrap the code.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s