The Code Editor

The Code Editor is a full-featured text editor for developing programs and executing program statements interactively. The exact behavior of the Code Editor depends on the syntax, or type, of code being edited. The editor currently supports four different syntaxes: Lisp, Sal (version 1 and 2), Fomus and Text. Each syntax has its own set of rules that define how symbols are colored (syntax hightlighting), how code is indented and how expressions are parsed and evaluated. The editor chooses between syntaxes based, in part, on the extension of the file you open:

Syntax File Extensions
Lisp .lisp .lsp .cl .scm .cm .clm .ins
SAL .sal .sal2 .sal1
Fomus .fms
Text .text .txt .*

Customizing the Editor

Use the Options menu to customize the Code Editor's visual characteristics and editing behavior. Option settings normally apply to the current window; you can save a setting as the "default global setting" in the application's preference file as well. You can customize editing for a particular file by adding a special customization comment at the top of the file. Customization comments look like this:

;;; -*- syntax: Sal2; font-size: 18; theme: "Emacs"; -*-

When the Code Editor opens a file it scans for these comment and, if they are present, the settings in the customization comment always override settings established by global preferences and file types. Use Options>Save Customizations to add a customization comment to the file you are editing. If you change a setting in a customization comment "by hand" after the file is open you can use the Options>Read Customizations to read the changed settings again. Customizations comments include the following settings:

Editing Mode

The Code Editor's editing mode controls what keyboard commands (shortcuts) are available to you during editing. The Code Editor supports two different editing modes: Standard mode and Emacs mode. Standard mode provides the standard set of Command key bindings used by most word processors:

Emacs mode implements Emacs-style commands and cursor motion over characters, words and expressions using its notion of Control and Meta keys. Note that on Linux and Windows the Command key IS the Emacs Control key so Standard shortcuts are disabled on these Operating Systems if Emacs mode is turned on (because Emacs mode claims that key as its Control key). On OS X the Command key is NOT the control key and so the Standard key commands are always available, even if Emacs Mode is turned on.

Standard Keyboard Commands

Cursor Motion

Include SHIFT with cursor commands to select text.
move character left
move character right
OPTION ←move word left
OPTION →move word right
COMMAND ←move to start of line
COMMAND →move to end of line
COMMAND ↑move line up
COMMAND ↓move line down
COMMAND ↑move to start of buffer
COMMAND ↓move to end of buffer

File Commands

COMMAND Nnew file
COMMAND Oopen file
COMMAND Ssave
COMMAND SHIFT Ssave as
COMMAND OPTION Ssave version
COMMAND Wclose window

Edit Commands

COMMAND Zundo
COMMAND SHIFT Zredo
COMMAND Xcut
COMMAND Ccopy
COMMAND Vpaste
COMMAND Aselect all
COMMAND Ffind and replace

Option Commands

COMMAND =font larger
COMMAND -font smaller

Syntax Dependant Commands

TABindent code
COMMAND RETURNexecute code
COMMAND Dget symbol documentation

Emacs Keyboard Commands

If Options>Emacs Mode is turned on then the Code Editor provides the Emacs commands listed below. Emacs commands are keystroke combinations involving the CONTROL and/or META keys combined with a key press. In the documentation that follows pressing CONTROL or META is shortened to C- and M- respectively. For example, C-f means to hold down the Control key and type the f key and C-M-f means to hold down both the Control and Meta keys while typing the f key.

Note: on OS X the Meta key is the Option key just right of the control key. On Linux and Windows the Meta key is the Alt key just to the left of the Spacebar.

Cursor Motion

C-fforward character
C-bbackward character
M-fforward word
M-bbackward word
C-M-fforward expression
C-M-bbackward expression

Line Motion

C-abeginning of line
C-eend of line
C-nnext line
C-pprevious line

Scrolling

C-vforward screen
M-vbackward screen
M->beginning of file
M-<end of file

Editing

C-ddelete character
M-ddelete word
C-M-kkill expression
C-kkill to end of line
C-yyank kill(s) back
C-oopen new line
M-llower case word
M-uupper case word
M-ccapitalize word
C-sfind and replace

File Commands

C-x C-fopen file
C-x C-ssave file
C-x C-wsave file to new name
C-x C-cclose window

Syntax Specific Commands

C-x C-eexecute code
TABindent line