Keyboard Maestro 8 “Code Commentor II” Macro
Author: Mike Pasini
Version: 2.1a
Last Update: 29 July 2018
Note: Version 2.1a replaces v2.0a. It uses a trigger variation rather than a unique character sequence to distinguish between multiline and single line commenting. Comments dated prior to July 29 refer to the original version. And those items, too, have been addressed in the new version.
This Keyboard Maestro macro automates adding or removing comment tags from a text selection in AppleScript, C, CoffeeScript, CSS, Haskell, HTML, PHP, Perl, Python, Ruby and JavaScript source files.
In languages that support multiline comments, multiline comment tagging is supported when you use the trigger chord Control-Option-#. Single line comments are used when you use the trigger chord Option-#.
The correct comment syntax is derived automatically from the window name of the currently opened file or, alternately, manually from a pick list (which remembers your last choice) when you hold the trigger key down.
If the comment tag for that type is not in the text selection, it's added. If it is, it's removed.
All you have to do is select a line or multiple lines of text or code in your source file and trigger the macro to toggle the comment.
Code Commentor II.v21a.zip (7.6 KB)