Programming 2D Games

The official forum for "Programming 2D Games" the book by: Charles Kelly

It is currently Mon Mar 19, 2018 10:38 am

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sun Jul 16, 2017 3:53 pm 
Site Admin
User avatar

Joined: Sat Jan 28, 2012 4:36 pm
Posts: 545
If you think the title to this post is something that should be trivial to do and not worthy of a post I would agree, that is until I spent that last two days trying to figure out how to do it. I finally came up with a workable solution that I will share here but it is by no means an optimal solution. If anyone has a better way please let me know.
My source code is in Visual Studio 2017. Line numbers are easy to add to the editor, Tools/Options/C/C++/General and check Line numbers.

The difficulty is in exporting the source with line numbers from VS to Word. In short, I never found a satisfactory way to do it. There are several plugins that sort of work but every one that I tried changed the formatting of the code or produced a document type that could not be imported into Word. The solution I finally got to work required using Notepad++. The steps required are very convoluted which is why I’m creating this post as a set of instructions for myself in the future.
    1. Configure Notepad++ to format the source code to your liking by going to Settings/Style Configurator…, selecting the desired language, C++ in my case, and adjusting the parameters for each item in the Style: list. In order to make the formatting match VS I added three user defined keywords under the INSTRUCTION WORD Style: pragma once and include.
    2. Copy the code from VS and past into Notepad++.
    3. Select the Language. Notepad++ should format the code.
    4. Select all of the code (CTRL+a).
    5. Press Space twice to indent the code.
    6. Place the cursor at the left margin in the first line.
    7. Edit/Column Editor… (ALT+C)
    8. Select Number to Insert
    ....a. Initial number: 1
    ....b. Increase by: 1
    ....c. Repeat: blank
    ....d. Click OK. Line numbers are added.
    9. Plugins/NppExport/Copy RTF to clipboard.
    10. Paste into Word document.

Easy right, sheesh! Talk about non-intuitive. Here is the final result in Word:

You do not have the required permissions to view the files attached to this post.

Professor Kelly

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group