Rmscript formatter

Hi
I am slowly but surely moving with the RM times and getting some of my reports re-written with the new way of using RM with scripts etc.

I like how the VS Code extension helps with some of the syntax, however, I am struggle to get it to format for me and it just asks me to install a formatter. Use case is where we have blocks of macro’s in old reports to be able to paste them in to VS Code and auto format into macro blocks line separating the options etc as its extremely time consuming but really find it useful being.

Happy to be corrected if I am missing a trick here.

Hi @drazzopardi

I’m not aware of a fully fledged pretty-print formatter for RMScript. I do recognise your use case though.

A good starting point is to use the in-built Search and Replace Regex capabilities. I have done a dual pass in the past.

  1. Put all the macros on separate lines
  2. Add a newline after each comma

This done by:

  1. Replacing “][” with “]\n[”
  2. Replacing ", " with “,\n\t”

‘Search and Replace’ is accessed via the Ctrl+H shortcut - don’t forget to check the [.*] radio button on the right of the Find field to set it to regex mode.

Please see example screenshots below (Sorry, adding a video seems not to be working this morning):

Before first replacement:

After first replacement:

Before second replacement:

After second replacement:

Not perfect, but hopefully, a quick and easy starting point…
(Note that this works in both Report Studio and VS Code)

1 Like

Thanks for the response and suggestion Adrian. I will give this a go and I am sure it will take some of the pain away.