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 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:
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 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 to read the changed settings again.
Customizations comments include the following settings:
- Code Syntax
- Color Theme
- Font Size
- Lines and Columns
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:
- On OS X the Command key is the Apple key just to the left of the Spacebar.
- On Linux and Windows the Command key is the Control key on the far left side of the keyboard
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 N | new file |
COMMAND O | open file |
COMMAND S | save |
COMMAND SHIFT S | save as |
COMMAND OPTION S | save version |
COMMAND W | close window |
Edit Commands
COMMAND Z | undo |
COMMAND SHIFT Z | redo |
COMMAND X | cut |
COMMAND C | copy |
COMMAND V | paste |
COMMAND A | select all |
COMMAND F | find and replace |
Option Commands
COMMAND = | font larger |
COMMAND - | font smaller |
Syntax Dependant Commands
TAB | indent code |
COMMAND RETURN | execute code |
COMMAND D | get symbol documentation |
Emacs Keyboard Commands
If 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-f | forward character |
C-b | backward character |
M-f | forward word |
M-b | backward word |
C-M-f | forward expression |
C-M-b | backward expression |
Line Motion
C-a | beginning of line |
C-e | end of line |
C-n | next line |
C-p | previous line |
Scrolling
C-v | forward screen |
M-v | backward screen |
M-> | beginning of file |
M-< | end of file |
Editing
C-d | delete character |
M-d | delete word |
C-M-k | kill expression |
C-k | kill to end of line |
C-y | yank kill(s) back |
C-o | open new line |
M-l | lower case word |
M-u | upper case word |
M-c | capitalize word |
C-s | find and replace |
File Commands
C-x C-f | open file |
C-x C-s | save file |
C-x C-w | save file to new name |
C-x C-c | close window |
Syntax Specific Commands
C-x C-e | execute code |
TAB | indent line |