Skip to content

Instantly share code, notes, and snippets.

@stokito
Created October 28, 2019 00:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stokito/9f7627a40eed42c2e7554cf4f7e85617 to your computer and use it in GitHub Desktop.
Save stokito/9f7627a40eed42c2e7554cf4f7e85617 to your computer and use it in GitHub Desktop.
replace single line comments // with multiline comments /*
Search pattern: (.*)(//)(.*)(\n)
Replace with: $1/\*$3 \*/$4
@stokito
Copy link
Author

stokito commented Oct 29, 2019

replace Write and WriteLn with padding to format()

Replace this

WriteLn(outSummary, '   ', i9: 4, '     ', aVals[0, 1]: 7: 3, '     ', format('%7.3f', [bVals[i9]]));

To this

WriteLn(outSummary, '   ', i9: 4, '     ', format('%7.3f', [aVals[0, 1]]), '     ', format('%7.3f', [bVals[i9]]));

Use this regexp and replacement:

(\s*Write)(Ln)?(\()(.*)(, ?)(.*\[.*\])(: ?)(\d\d?)( ?)(: ?)(\d\d?)(.*\).*\n)
$1$2$3$4$5format('%$8.$11f', [$6])$12

Replace this

Write(scratch, examineeNum: 4, theta: 10: 4, mlSem: 10: 4, adaptiveItemNo: 9, finTheta: 13: 4, finSem: 10: 4, delta: 10: 4, format('%10.4f', [semDiff]));

To this

Write(scratch, examineeNum: 4, format('%10.4f', [theta]), format('%10.4f', [mlSem]), adaptiveItemNo: 9, format('%13.4f', [finTheta]), format('%10.4f', [finSem]), format('%10.4f', [delta]), format('%10.4f', [semDiff]));

Use this regexp and replacement:

(\s*Write)(Ln)?(\()(.*)(, ?)(.*)(: ?)(\d\d?)( ?)(: ?)(\d\d?)(.*\).*\n)
$1$2$3$4$5format('%$8.$11f', [$6])$12

Here is a problem:

  WriteLn(outSummary, i6 : 5, '    ', count[i6] : 5, '  ', cumFreq : 5, '      ', format('%7.3f', [pct ]), '   ', format('%9.3f', [cumPct ]));

Incorrectly replaced to:

  WriteLn(outSummary, i6 : 5, '    ', format('%5.0f', [count[i6] : 5, '  ', cumFreq ]), '      ', format('%7.3f', [pct ]), '   ', format('%9.3f', [cumPct ]));

Fix it manually, I don't know how to avoid this.

Replace this

 WriteLn(outSummary, i6 : 5, '    ', count[i6] : 5, '  ', cumFreq : 5, '      ', format('%7.3f', [pct ]), '   ', format('%9.3f', [cumPct ]));

To this

 WriteLn(outSummary, i6 : 5, '    ', count[i6] : 5, '  ', format('%5.0f', [cumFreq ]), '      ', format('%7.3f', [pct ]), '   ', format('%9.3f', [cumPct ]));

Use this regexp and replacement:

(\s*Write)(Ln)?(\()(.*)(, ?)(.*)(: ?)(\d\d?)( ?)(.*\).*\n)
$1$2$3$4$5format('%$8.0f', [$6])$10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment