CotEditor Scripting

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

[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 flexible, UNIX scripts can only modify contents of the frontmost document. However, as for UNIX scripts, you can write them in various languages, for example; Python, Ruby, Perl and so on. Choose a script type to suit your use. For details about how to write your scripts, refer to Working with AppleScript scripts or Working with UNIX scripts.

Get existing CotEditor scripts

The CotEditor project provides some sample scripts. You can get them on:
coteditor/SampleScripts -GitHub

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

See also