Automate tasks with scripting in CotEditor on Mac

Run your own scripts on CotEditor to modify documents or launch external tools. Your scripts appear in the Script menu represented with script icon.

Screenshot of the Script menu

On CotEditor, there are two different ways to write scripts:

AppleScript
AppleScript and JavaScript for Automation (JXA) can control documents in CotEditor with a high level of flexibility.
UNIX script
UNIX scripts can modify only 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 CotEditor app on your Mac.

  2. Choose Script menu > Open Scripts Folder.

    The Finder opens the folder for CotEditor scripts at:
    ~/Library/Application Scripts/com.coteditor.CotEditor/

  3. Put your script files in this folder, or remove unwanted ones.

    CotEditor 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

The CotEditor project provides sample scripts. You can download them from:
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