Script CotEditor on Mac

CotEditor has a scripting feature that lets you run your own scripts on CotEditor to manipulate documents or launch external programs. Your scripts are shown in the Script menu represented with script icon.

[Script menu]

Scripting types

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

While AppleScript (incl. JXA; JavaScript for Automation) can control CotEditor’s document more flexibly, UNIX scripts can only modify the contents of the frontmost document. However, as for UNIX scripts, you can write them in various languages, such as Python, Ruby, Perl, and so on. Choose a script type that suits your use. For details about how to write your scripts, refer to Script CotEditor with AppleScript or Script CotEditor with UNIX script.

Add/delete scripts

To add scripts to or remove scripts from the Script menu, follow the instruction below:

  1. Choose Script > Open Scripts Folder in CotEditor and the Finder opens the folder for CotEditor scripts at:
    ~/Library/Application Scripts/com.coteditor.CotEditor/
  2. Put your script files in this folder, or remove them from there.
  3. The changes you made inside the scripts folder are automatically reflected in the menu.

You can 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 some sample scripts. You can get them on:
coteditor/SampleScripts -GitHub

Some users may distribute their scripts for CotEditor online. Some of them are listed on:
CotEditor Scripts -CotEditor Wiki

See also