Script :: Toggle Comment (note)

I made a simple script that many plain text editors have for toggling comments.
(Of course it has to be ⌘/, which takes up the Show Status Bar shortcut)

tell front document of application "Bike"
	set ls to selection rows
	repeat with each in ls
		if type of each is body then
			set type of each to note
		else if type of each is note then
			set type of each to body
		end if
	end repeat
end tell

FWIW a variant in JS.

(Its behaviour differs only when rows of different types have been selected – toggles all selected rows together, basing the toggle direction on the type of the first selected row).

Expand disclosure triangle to view JS source
(() => {
    "use strict";

        specialType = "note",
        defaultType = "body";

        bike = Application("Bike"),
        doc =;

    return doc.exists()
        ? (() => {
                selectedRows = doc.rows.where({
                    selected: true
                n = selectedRows.length;

            return 0 < n
                ? (() => {
                        toggledType = specialType === (
                            ? defaultType
                            : specialType;

                    return (
                            row => row.type = toggledType
                        `${n} row(s) -> ${toggledType}`
                : `Nothing selected in '${}'`;
        : "No document open in Bike.";

To test in Script Editor, set language selector at top left to JavaScript.

See: Bike – Using Scripts

i.e. equivalent, in AppleScript terms, to something like:

Expand disclosure triangle to view AppleScript source
tell front document of application "Bike"
	if it exists then
		set selectedRows to a reference to (rows where selected is true)
		if 0 < (count of selectedRows) then
			if body is type of (item 1 of selectedRows) then
				set toggleType to note
				set toggleType to body
			end if
			set type of selectedRows to toggleType
			toggleType as text
			"Nothing selected in '" & name & "'."
		end if
		"No document open in Bike."
	end if
end tell