Developer Tools

Hash Comment

Prefix every selected line with a hash comment.

OfficialOn-device

Download action

What Hash Comment does

Prefix every selected line with a hash comment. It runs locally and handles the selected text without contacting a service.

CategoryDeveloper Tools
Action typeJavaScript
Default resultReplace or copy text
InternetNot required

Action and outcome

Hash Comment example
ActionOutcome
Hash CommentSelected text: first second# first # second

Use Hash Comment

Follow these steps to prefix every selected line with a hash comment with ActionClip.

  1. Select the text you want to use.
  2. Choose Hash Comment from ActionClip.
  3. Review the result, then replace the selection or copy the new text.

Requirements and privacy

  • Before you start: No setup required.
  • Your selected text: Runs locally in ActionClip’s JavaScript sandbox. Selected text does not leave your Mac.

Action script

The script below is included so you can inspect how the action works before downloading it.

JavaScript definition
function run(selected_text) {
  return selected_text.replace(/\r\n?|\u2028|\u2029|\u0085|\u000B|\u000C/g, "\n")
    .split("\n")
    .map(function (line) { return "# " + line; })
    .join("\n");
}