Can I write scripts and macros in CotEditor?

Updated

Yes. CotEditor is scriptable, and according to the project's own feature list you can write your own macros in Python, Ruby, Perl, PHP, UNIX shell, AppleScript, or JavaScript. This applies to macOS users who want to automate repetitive text work inside the editor rather than switching to a separate scripting environment.

What "scriptable" means in CotEditor

CotEditor is a plain-text editor built specifically for macOS. Its scripting support is presented as a way to "make your own macro in your favorite language," so the practical idea is: you write a script in a language you already know, and CotEditor runs it as a macro against your document.

The supported languages listed on the site are:

  • Python
  • Ruby
  • Perl
  • PHP
  • UNIX shell
  • AppleScript
  • JavaScript

Because the list mixes general-purpose languages with macOS automation tools, you can pick based on the task. AppleScript fits macOS-level automation, while Python, Ruby, Perl, PHP, shell, and JavaScript fit text transformation and processing.

How this fits with the rest of the editor

Scripting is one feature among several aimed at people who work with text regularly. Related capabilities from the same feature set include:

Feature What it does
Syntax Highlighting Colorizes 60+ pre-installed languages, including HTML, PHP, Python, Ruby, and Markdown; custom settings allowed
Find & Replace Uses the ICU regular expression engine
Outline Menu Extracts specified lines using predefined syntax and jumps to the matching line
Split Editor Splits a window into panes to view different parts of a document
Character Inspector Shows Unicode data for selected characters in a popover
Incompatible Characters Lists characters that cannot convert to a chosen encoding
CJK Language Friendly Estimates file encodings, supports vertical text mode, and keeps line height correct

For scripting specifically, the Find & Replace engine and syntax definitions matter because a macro often needs to locate patterns and rewrite them. The site also notes that all settings, including syntax definitions and themes, are reachable from a standard settings window rather than complex configuration files.

Who this is for

Scripting in CotEditor suits users who want to automate text processing without leaving the editor. Typical situations include:

  • Reformatting or cleaning up repeated text patterns
  • Running a small Python or Ruby routine over a document
  • Using AppleScript to tie editor actions into macOS workflows
  • Writing shell-based transformations for plain-text files

If your work is mostly manual editing, the other features (syntax highlighting, outline navigation, split view) may matter more. If your work involves repeated transformations, the multi-language scripting support is the relevant reason to choose CotEditor.

Practical notes

  • The site describes CotEditor as free, lightweight, and open source, with development on GitHub and feedback handled through an issue tracker.
  • It is made only for macOS, so scripting assumes a macOS environment.
  • The feature list does not specify script APIs, file locations, or execution details, so exact setup should be confirmed in the app itself or the project's documentation.
  • Auto Backup is included, which reduces the risk of losing unsaved data while editing or testing scripts.