Leo (text editor)

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Leo: Leonine Editor with Outlines
Developer(s) Edward K. Ream
Stable release 4.11 final / November 6, 2013; 8 months ago (2013-11-06)
Written in Python
Operating system Cross-platform
Type Text editor, Outliner, IDE
License MIT License
Website http://leoeditor.com/

Leo (Leonine Editor with Outlines) is a text editor that features outlines with clones as its central tool of organization, navigation, customization and scripting.


Leo is written in Python. The GUI currently makes use of the Qt toolkit; until version 4.7, there was an older GUI based on Tk. Outlines can contain Python scripts, while Leo itself can be extended with plugins (also written in Python). Leo's documents are XML files.

Trees, clones and views[edit]

Leo is an outliner. Leo's outline pane shows a tree of data nodes. Nodes contain headlines, body text, and other information. Headlines naturally serve as descriptions of the body text. For example, @file nodes are nodes whose headline starts with @file. Leo trees are in fact directed acyclic graphs; nodes may have more than one parent. Leo calls such nodes clones. Clones appear in several places in the outline pane. Views are simply nodes whose children contain clones. A single outline may contain arbitrarily many views of the nodes contained therein.

External files[edit]

@file nodes represent external files, files on the computer's file system other than the outline file. When saving an outline Leo automatically writes all changed @file trees back to the external files. Comments, called sentinel lines, in external files represent the outline structure. When Leo reads an outline, these comments allow Leo to recreate @file trees using only the data in the external file. @auto nodes represent external files without using sentinel comments. When reading @auto nodes, Leo uses the program structure of the external file to create the @auto tree.


The body text of any node may contain a Leo script, a Python script executed in the context of a Leo outline. A simple API gives Leo scripts full access to all data in loaded outlines, as well as full access to Leo's own source code. The API includes Python iterators that allow scripts to traverse outlines easily. Scripts may be composed of any tree of nodes. A markup language similar to noweb tells Leo how to create scripts from (parts of) an outline. Headlines naturally control and guide scripts. Examples are:

  • @test nodes create unit tests. Leo executes the body of an @test node as unit test, without the body having to create an explicit subclass of Python's UnitTest.TestCase class.
  • @button nodes create user-defined commands. Leo executes the script of an @button node in the context of any other outline node.


External links[edit]