Vim commands to write out parameter list
Executive summary :)
For each line
0
D
PP
From the colon prompt:
%s/^ */ write-dbg "`
%s/ *\$/: <\$
%s/$/>"
%s/,//g
The gory details
Starting with a parameter clause like this:
Param(
$Parameter1,
$Parameter2,
$Parameter3,
$Parameter4
)
The manual bits
First, take off the ‘Param(i’, and the bracket at the end
Second, for each line do this:
0
D
PP
… to get:
$Parameter1, $Parameter1,
$Parameter2, $Parameter2,
$Parameter3, $Parameter3,
$Parameter4 $Parameter4
The colon prompt bits
Replace spaces at the front with the write-dbg, a double-quote, and then a backtick. The backtick is because I need to escape the name of the variable
:%s/^ */ write-dbg "`
This gives:
write-dbg "`$Parameter1, $Parameter1,
write-dbg "`$Parameter2, $Parameter2,
write-dbg "`$Parameter3, $Parameter3,
write-dbg "`$Parameter4 $Parameter4
Replace the spaces between the repeated variables with ‘: <’
:%s/ *\$/: <\$
….giving:
write-dbg "`$Parameter1,: <$Parameter1,
write-dbg "`$Parameter2,: <$Parameter2,
write-dbg "`$Parameter3,: <$Parameter3,
write-dbg "`$Parameter4: <$Parameter4
End the string:
%s/$/>"
….which gives:
write-dbg "`$Parameter1,: <$Parameter1,
write-dbg "`$Parameter2,: <$Parameter2,
write-dbg "`$Parameter3,: <$Parameter3,
write-dbg "`$Parameter4: <$Parameter4
Finally get rid of the commas
%s/,//g
Leaving:
write-dbg "`$Parameter1: <$Parameter1>"
write-dbg "`$Parameter2: <$Parameter2>"
write-dbg "`$Parameter3: <$Parameter3>"
write-dbg "`$Parameter4: <$Parameter4>"