Automate tasks with scripting in Textmode on Mac

Run your own scripts in Textmode to modify documents or launch external tools. Your scripts appear in the Script menu, represented by the script icon.

In Textmode, you can write scripts in two main ways:

AppleScript
AppleScript and JavaScript for Automation (JXA) can control documents in Textmode with a high level of flexibility.
UNIX script
UNIX scripts primarily operate on the frontmost document, but you can write them in various languages such as Python, Ruby, and Swift.

Choose the scripting type that suits your needs. For details about how to write your scripts, see Automate tasks using AppleScript or Automate tasks using UNIX scripts.

Add scripts to or remove scripts from the Script menu

  1. Go to the Textmode app on your Mac.

  2. Choose Script menu > Open Scripts Folder.

    The Finder opens the folder for Textmode scripts at:
    ~/Library/Application Scripts/com.tidymachines.textmode/

  3. Add your script files to this folder, or remove any you no longer need.

    Textmode automatically applies changes in this folder to the Script menu.

You can also change the order of scripts or assign keyboard shortcuts by modifying the names of your script files. See Customize the Script menu for the details.

Get existing CotEditor scripts

Textmode runs scripts written for CotEditor. In a script that names the app, such as tell application "CotEditor", change the name to Textmode.

The CotEditor project provides sample scripts:
coteditor/SampleScripts -GitHub

Some users also distribute their own scripts for CotEditor. A selection of these scripts is listed at:
CotEditor Scripts -CotEditor Wiki

See also