This is an example of using the Better Comments extension for CFML development in VSCode .
The Better Comments extension visually highlights specially tagged comments (like TODO, !, or ?) using colors and styles so important notes, questions, and tasks stand out instantly in your code.
You can define custom styles in either User or Workspace settings.json. You can set the color or backgroundColor, as well as underline, strikethrough, bold, and italic.
Gotcha 1: You must define all better-comments.tags in one location. Better Comments does not merge tag arrays.
Gotcha 2: When using CFML block comments in tag-based ColdFusion files, you must use // as the first non-whitespace characters after the opening comment tag for Better Comments to recognize the comment type.
Changes to settings may require reloading the VS Code window to take effect:
CMD+SHIFT+P > Developer: Reload Window
Results below:
Better Comments extension for CFML development in VSCode
Here is a helpful workspace configuration option(s) that allows you to set the default terminal profile (terminal.integrated.defaultProfile.YOUR_OS) to CommandBox in VSCode terminal. This allows you to launch CommandBox by default when you open a terminal in the workspace. Further, you can specify the current working directory (terminal.integrated.cwd) so any new terminal you open in the workspace will start in that directory.
These settings are stored in YOUR_WORKSPACE.code-workspace so you can set them on a per workspace basis.
YOUR_OS = the OS you are running
YOUR_WORKSPACE = whatever the .workspace file is for your current workspace.
This post is a follow up to a topic I originally posted titled Run CommandBox directly inside VSCode Terminal which explained setting up a custom terminal profile (terminal.integrated.profiles.YOUR_OS) for CommandBox.
I’d like to revisit the CFML Formatter (VSCode extension) that I posted on not too long ago and mention the cfformat-ignore functionality.
I had to work on some 15+ year old code today. I won’t say who wrote that code. Cough Me. Cough Embarrassing. Every time I saved a file the CFML Formatter was working overtime to try to figure out how to get the code formatted. Long story short there were a few blocks involving concatenation that ended up throwing errors after they were reformatted. Due to time constraints I needed to put a pin in figuring how to rewrite the offending blocks and just needed cfformat to ignore those blocks.
In a nutshell there are 3 ways to do it depending on the block of code.
I don’t work on a lot of non-CFML development but I had a couple of PHP projects and a JavaScript project I was working on last month. In an effort to tidy up my code in those projects I started using Prettier. I even wrote a post on Prettier and how I would be including it in future projects. Well, this weekend I was working on a CFML project and came across Mark Drew’s incredible CFML formatter extension for Visual Studio Code. Per the documentation:
CFML formatter is a Visual Studio Code extension that provides formatting for CFML files using Lucee Server and CFFormat
Set and implement coding standards for yourself and/or your team.
Format code in real time as you work in Visual Studio Code.
Scan, review, and even format code issues manually or in an automated manner by watching directories.
Installation
CFML formatter
Install the CFML formatter VSCode extension from the Extensions view in Visual Studio Code.
cfformat
Install the cfformat CommandBox module by launching CommandBox and running the following command.
box install commandbox-cfformat
A few things you can do with CFML formatter
Format code on save
This will format your code using CFML formatter every time you save a file in Visual Studio Code (you can define the rules using a .cfformat.json file which you can also share with your team!).
To configure Format code on save:
Open Settings by pressing Cmd+, for Mac (or CTRL+, for Windows/Linux).
Type format in the search box and enable the option Format On Save.
Format on save in VSCode
Format code using right click
This will format your code using CFML formatter when you right click in the Visual Studio Code editor and choose Format Document
Display the options AND what those options will do to an example of code.
Indicate the default setting.
Generate a .cfformat.json file for you based on your choices.
This wizard option is incredible!
View existing settings
cfformat settings show
cfformat settings show command in CommandBox
These settings can be stored in a .cfformat.json file in your Visual Studio Code project. They will then govern Format code on save and the Format Document on right click action.