This chapter lists almost all of Leo’s commands. It starts with a discussion of the Emacs-like minibuffer.
Leo’s minibuffer appears at the bottom of Leo’s main window. You use the minibuffer to execute commands by name, and also to accumulate arguments to commands.
Every Leo command has a command name. In this document, keystrokes that invoke a command will be followed by the command name in parentheses. For example, Ctrl-S (save-file)
saves a Leo file.
Very Important: Leo has hundreds of commands, but because of tab completion you do not have to remember, or even know about any of them. Feel free to ignore commands that you don’t use. The following prefixes help find commands by name:
clone-find clone-find commands
file- file commands
find- find commands
isearch- incremental search commands
leo- open .leo files
open- open files or url's
print- print commands
rectangle- rectangle commands
sort- sort commands
toggle- toggle settings commands
Here are the commands that pertain to executing commands:
Alt-X (full-command)
Executes any other command by typing its full name.
Ctrl-P (repeat-complex-command
Repeats the last command entered by name in the minibuffer.
When in the minibuffer, the following keys are treated in special ways:
<Return>
Executes the command.
<Tab>
Shows all valid completions.
<BackSpace>
Shows more completions.
Ctrl-G
Exits the minibuffer and puts focus in the body pane.
UpArrow
Moves backward through command history. The first UpArrow
is the same as Ctrl-P
.
DownArrow
Moves forward through command history.
Very Important: Leo has hundreds of commands, but because of tab completion you do not have to remember, or even know about any of them. Feel free to ignore commands that you don’t use.
You could type the full command name in the minibuffer, followed by the <Return>
key to invoke the command, but that would be way too much work. Instead, you can avoid most typing using tab completion. With tab completion, there is no need to remember the exact names of Leo’s commands.
For example, suppose you want to print out the list of Leo’s commands. You might remember only that there are several related commands and that they all start with “print”. Just type <Alt-X>pri<Tab>
You will see print-
in the minibuffer. This is the longest common prefix of all the command names that start with pri
. The Completion tab in the log pane shows all the commands that start with print-
.
Now just type c<Tab>
You will see the print-commands
command in the minibuffer.
Finally, <Return>
executes the print-commands
command. The output of the print-commands
command appears in the commands tab, and focus returns to the body pane.
file-open-by-name
Prompts for a filename. This command completes the name of files and directories as in command completion. As a result, this command can be very fast. You may want to bind this command to Ctrl-O
instead of the default open-outline
command.
Here are Leo’s basic file commands:
Ctrl-N (new)
Creates a new outline in a new tab.
Ctrl-O (open-outline)
Opens an existing .leo file.
Ctrl-S (save-file)
Saves the outline.
Ctrl-Q (exit-leo)
Exits Leo. Leo will prompt you to save any unsaved outlines.
A session specifies a list of .leo files that Leo opens automatically when Leo first starts. Leo will reload the last session provided that command-line arguments don’t contain any file names.
Here’s how to switch focus without using the mouse:
Alt-0 (vr-toggle)
Hides or shows the viewrendered pane.
Alt-T (focus-to-tree)
Puts focus in the outline pane, regardless of focus.
Ctrl-T (toggle-active-pane)
Toggles focus between the outline and body panes.
Ctrl-Tab (tab-cycle-next)
Switches between outline tabs. You may open multiple Leo outlines in different tabs within the same main window.
Ctrl-G (keyboard-quit)
Puts focus in the body pane. More effective than hitting Alt-Tab twice.
Ctrl-I or Insert (insert-node)
Inserts a new node into the outline.
Ctrl-H (edit-headline)
Begins editing the headline of the selected node.
Return
When focus is in the outline pane, <Return>
ends editing (end-edit-headline)
or switches focus to the body pane.
Ctrl-Shift-C (copy-node)
Copies the outline and all it’s descendants, placing the node on the clipboard.
Ctrl-Shift-X (cut-node)
Cuts the outline and all its descendants, placing the node on the clipboard.
Ctrl-Shift-V (paste-node)
Pastes a node (and its descendants) from the clipboard after the presently selected node.
Ctrl-M (mark)
Toggles the mark on a node. Marked nodes have a vertical red bar in their icon area.
Ctrl-} (demote)
Makes all following siblings of a node children of the node. Use demote
to “gather” nodes so they can all be moved with their parent.
Ctrl-{ (promote)
Makes all the children of a node siblings of the node. Use demote
to “scatter” the nodes after moving their parent.
You may select, expand and contract outline nodes with the mouse as usual, but using arrow keys is highly recommended. When focus is in the outline pane, plain arrows keys change the selected node:
Right-arrow (expand-and-go-right)
Expands a node or selects its first child.
Left-arrow (contract-or-go-left)
Contracts a node if its children are visible, and selects the node’s parent otherwise.
Up-arrow (goto-prev-visible)
Selects the previous visible outline node.
Down-arrow (goto-next-visible)
Selects the next visible outline node.
Regardless of focus, Alt-arrow
select outline nodes:
Alt-Home (goto-first-visible-node)
Selects the first outline node and collapses all nodes.
Alt-End (goto-last-visible-node)
Selects the last visible outline node and collapses all nodes except the node and its ancestors.
Alt-arrow keys
Select the outline pane, and then act just like the plain arrow keys when the outline pane has focus.
When focus is in any of Leo’s text panes (body pane, log pane, headlines), Leo works like most text editors:
Plain arrow
keys move the cursor up, down, left or right.
Ctrl-LeftArrow
and Ctrl-RightArrow
move the cursor by words.
Home
and End
move the cursor to the beginning or end of a line.
Ctrl-Home
moves the cursor to the beginning of the body text.
Ctrl-End
moves the cursor to the end of the body text.
PageDown
and PageUp
move the cursor up or down one page.
Note: As usual, adding the Shift
key modifier to any of the keys above moves the cursor and extends the selected text.
This section explains how to use Leo’s standard search/replace commands.
Note: you can also use the Nav Tab (in the Log pane) to search for text.
Ctrl-F (start-search)
shows the Find Tab and puts the focus in the text box labeled Find:
.
Aside: You can select radio buttons and toggle check boxes in the Find Tab with Ctrl-Alt keys
. The capitalized words of the radio buttons or check boxes indicate which key to use. For example, Ctrl-Alt-X (toggle-find-regex-option)
toggles the regeXp
checkbox.
After typing Ctrl-F
, type the search string, say def
, in the text box.
Start the find command by typing <Return>
.
But suppose you want to replace def
with foo
, instead of just finding def
.
Just type <Tab>
before typing <Return>
. Focus shifts to the text box labeled Replace:
.
Finally, type <Return>
to start the find-next
command. When Leo finds the next instance of def
, it will select it.
You may now type any command. The following are most useful:
Ctrl-minus (replace-then-find)
replaces the selected text.
F3 (find-next)
continues searching without making a replacement.
F2 (find-previous)
continues the search in reverse.
Ctrl-G (keyboard-quit)
ends the search.
rst3
Converts @rst
nodes to restructured text. This command automatically creates underlining for rST sections. To reorganize a document, just reorganize the corresponding Leo outline: you don’t have to change markup by hand. Search or “rst” in leoSettings.leo
to see the pertinent settings.
adoc
Converts @adoc
nodes to asciidoc text. This command automatically creates markup for asciidoctor sections. To reorganize a document, just reorganize the corresponding Leo outline: you don’t have to change markup by hand.
Leo has unlimited undo–Leo remembers all changes you make to outline structure or the contents of any node since you restarted Leo.
Ctrl-Z (undo)
Undoes the last change. Another Ctrl-Z
undoes the previous change, etc.
Ctrl-Shift-Z (redo)
Undoes the effect of the last undo, etc.
The first two entries of the Edit
menu show what the next undo or redo operation will be.
The clone find commands, cfa and cff are extraordinarily useful. These commands move clones of all nodes matching the search pattern under a single organizer node, created as the last top-level node. Flattened searches put all nodes as direct children of the organizer node:
cfa clone-find-all
cff clone-find-all-flattened
The clone-marked commands move clones of all marked nodes under an organizer node. Especially useful for gathering nodes by hand:
cfam clone-find-marked
cffm clone-find-flattened-marked
The check-nodes command finds dubious nodes, that is, nodes that:
This command is specially useful when using @clean
nodes in a collaborative
environment. Leo’s @clean
update algorithm will update @clean
nodes when
others have added, deleted or moved code, but the update algorithm won’t
assign changed code to the optimal nodes. This script highlights nodes that
needed attention.
Settings: You can customize the behavior of this command with @data
nodes:
@data check-nodes-ok-patterns
The body of the @data
node contains a list of regexes (strings), one per
line. This command compiles each regex as if it were a raw string.
Headlines matching any of these compiled regexes are not considered
dubious. The defaults ignore unit tests:
@data check-nodes-ok-prefixes
The body of the @data
node contains a list of strings, one per line.
Headlines starting with any of these strings are not considered dubious.
The defaults ignore top-level @<file> nodes and marker nodes:
@data check-nodes-suppressions
The body of the @data
node contains a list of strings, one per line.
Headlines that match these suppressions exactly are not considered
dubious. Default: None.
F1 (help)
Shows a help message appears in the viewrendered pane. Alt-0
(vr-toggle
) hides or shows this pane.
F11 (help-for-command)
Shows the documentation for any Leo command. F11
prompts for the name of a Leo command in the minibuffer. Use tab completion to see the list of all commands that start with a given prefix.
F12 (help-for-python)
Shows the documentation from Python’s help system. Typing completion is not available: type the full name of any Python module, class, function or statement.
These commands clarify which settings are in effect, and where they came from:
print-bindings
print-settings
These commands discuss special topics:
help-for-abbreviations
help-for-autocompletion
help-for-bindings
help-for-creating-external-files
help-for-debugging-commands
help-for-drag-and-drop
help-for-dynamic-abbreviations
help-for-find-commands
help-for-minibuffer
help-for-regular-expressions
help-for-scripting
xdb
Start a Leo’s integrated debugger in a separate thread.
Start the debugger from any part of any @<file> tree. Now you are ready
to execute all the db-* commands.
You can execute these commands from the minibuffer, or, if the
xdb_pane.py plugin is enabled, from the the Debug pane.
The following commands correspond to the pdb commands:
db-b
Set a breakpoint at the line shown in Leo.
It should be an executable line.
db-c
Continue, that is, run until the next breakpoint.
db-h
Print the help message (in the console, for now)
db-l
List a few lines around present location.
db-n
Execute the next line.
db-q
End the debugger.
db-r
Return from the present function/method.
db-s
Step into the next line.
db-w
Print the stack.
There are two additional commands:
db-again
Run the previous db-command
.
db-input
Prompt for any pdb command, then execute it.
The db-input
command allows you can enter any pdb command at all.
For example: “print c”.
But you don’t have to run these commands from the minibuffer, as discussed next.
Setting breakpoints in the gutter
When @bool use_gutter
is True, Leo shows a border in the body pane. By default, the line-numbering.py
plugin is enabled, and if so, the gutter shows correct line number in the external file.
After executing the xdb command, you can set a breakpoint on any executable line by clicking in the gutter to the right of the line number. You can also set a breakpoint any time the debugger is stopped.
Using the gutter is optional. You can also set breakpoints with the db-b
command or by typing d line-number
or d file-name:line-number
using the db-input
command, or by using the Debug pane (see below)
The Debug pane
The xdb_pane.py plugin creates the Debug pane in the Log pane. The pane contains buttons corresponding to all the commands listed above. In addition, there is an input area in which you can enter pdb commands. This is a bit easier to use than the db-input
command.
Settings
When @bool use_xdb_pane_output_area
is True, all debugger output is sent to an output area in the Debug pane. The default is True, so you need this setting only if you don’t want output set to the Debug pane.
These commands make it easier to use Leo’s reference .leo files. From time to time, developers needs to open reference Leo file and copy its content to and from their personal file. These commands use a separation node, a top-level node whose headline is:
The body of the separation node contains the .leo reference, a path to the reference .leo file. Everything above this node is the public part of the outline. Everything below this node is the private part of the outline.
set-reference-file selects the reference .leo file corresponding to the local .leo file. It creates the separation node if it doesn’t exists, changing the .leo reference as needed.
read-ref-file reads the public part of this outline from the reference .leo file given in the separation node. Warning: This command deletes all nodes above separation node, recreating them from the reference file.
update-ref-file saves public part of this outline to reference .leo file.
Developers will typically execute the read-ref-file
command after any git pull that changes any reference .leo file. Similarly, devs will typically execute the update-ref-file
command before doing a git commit that changes a reference .leo file.