Is it possible to comment a macro and replay it.
Example
instead of
dddwj
I would like to comment and execute following fragment
dd # Delete line
dw # Delete word
j # Move to next line
Some background
We use PICT to generate testcase inputs (All Pair testing). As this is an iterative process, the macro for generating code needs tweaking between subsequent runs. It’s hard to modify a macro when everything is on one line, without comments.
The output of a PICT run might be something like this:
1 cInstallationX Pu380
2 cInstallationY U400
wich can be converted to testcases with a macro
procedure TWatchIntegrationTests.Test1;
begin
//***** Setup
builder
.withInstallation(cInstallationX)
.withIsotope(Pu380)
.Build;
//***** Execute
CreateAndCollectWatches;
//***** Verify
VerifyThat
.toDo;
end;
procedure TWatchIntegrationTests.Test2;
begin
//***** Setup
builder
.withInstallation(cInstallationY)
.withIsotope(U400)
.Build;
//***** Execute
CreateAndCollectWatches;
//***** Verify
VerifyThat
.toDo;
end;
I don’t know a good way of doing this with macros, but there are a few options that I can see that might help:
Heavy use of ‘normal’
This is the closest to your macro option, but not very nice: make your saved file look like this:
Complicated Substitution
This makes use of regular expressions, but makes those regular expressions be well commented (this is based on your actual example).
Stick it in a function
Given that this is getting rather complicated, I’d probably do it this way as it gives more room for adjustment. As I see it, you want to split the line on white space and use the three fields, so something like this:
Do it in python
This is the sort of task that is probably easier to do in python:
To use this, save it as (e.g.)
pict_convert.pyand run:It will produce
input_file.txt.outputas a result.