Commenting Source in RDi

Source Commenting

I'm talking about commenting your source with references to projects. Each project we undertake is assigned a 5 digit project reference number. Code changes made for a particular project are commented with this reference. The reference number fits conveniently in positions 1 to 5 or the source, whether coding in fixed format or free.

Does this describe the way you annotate your code changes? If so, read on.

If you are commenting a huge block of code with no breaks, you could mark out the top left of the comment area with alt + r and then mark out the bottom right with alt + r and then right click in the source > Selected > Fill selection, type in the reference number and press Enter. Doing so applies the "comment" to all selected lines in the marked out area.

However, if you have breaks in the code where you don't want to add the comment, it's unwieldy to go through the whole rigmarole of marking out areas with alt + r. Instead, you can use the macro recorder in RDi.

Click on the Start recording button in the toolbar (towards the right).

Start Recording Macro

Type in your project reference and then position the cursor at the start of the next line, precisely where you would start annotating the next line of code. Click Stop recording. It's right next door to the Start recording button.

Stop Recording Macro

The macro has been recorded! To use the macro, click on the green right arrow (Playback recording).

Playback Recording

Add comments like a demon! Obviously, record yourself annotating the number of lines that occurs the most frequently. That is, if most of your code is grouped like 3 lines of code, a blank line, 3 lines of code, a blank line, etc. Then record yourself adding your comment to 3 consecutive lines. It will be quicker to manually add comments to the exceptions.