VS Code Beautify CFM - cfset tags

63 views Asked by At

I have installed the Beautify extension in VS code and it works great for HTML and most ColdFusion code but the one thing I cannot seem to configure is the tag. When we have it works fine. If we have (without the closing /> ) it treats is like it should be indented and so we end up with:

<cfset var myVar = "some value">
     <cfset var myVar = "some value">
          <cfset var myVar = "some value">

I understand that the solution would be to close all of the tags manually, but we have thousands sitewide. Does anyone have a configuration to ignore these, or better yet, close them?

Thank you

1

There are 1 answers

0
AndreasRu On

I had a very similar issue and had to close various tags. So I've created a RegEx to replace every occurrence within a file editor, such as VsCode with the command to "Edit" > "Replace in files" und using the RegEx filter. That may work for you also. Please backup your source code first and please use with care, because the source code I've needed to use it wasn't too big. Also, this RegEx will change more single cftags, e.g. <cfinclude>, <cfheader>,<cfdump>, etc. and close them also. Adapt the RegEx as needed.

RegEx:

/(<cf)(set|else|abort|include|queryparam|header|mailparam)(.*?)(?:\s*\/|)>/

Replace with:

$1$2$3 />