Code Editor
Notice that some aspects of the editor can be customized. Especially the keyboard
shortcuts are defined in a file called "keyboard.rc
" which is loaded at startup time.
If you don't like the default keyboard settings as described below,
feel free to place your own "keyboard.rc
" file
into the ST/X executable's startup folder
or into your private "~/.smalltalk
" directory.
Most menu functions operate on the current text selection.
The menu is hierarchical, with less frequently used operations
to be found in submenus named "More" or "Other".
Shortkey commands are initialted by keeping either "Ctrl" and/or "Cmd"
(also named "Alt" or "Meta" on some keyboards).
On the Mac, using the XWindow version of ST/X,
the "Apple-Cmd" key is reserved for Window manager operations,
and not usable in ST/X, unless you have installed a custom keybord modifier map.
Here, the "Alt" key located next to the Cmd key is used (which may be annoying at times).
Shortkey commands are also described in the introductionary text,
"Editing Text",
so the following is only a reminder about the most common functions.
Shortkey commands are roughly grouped into
- Cursor Movement Keys
- Selection Keys
- Operation Keys (general)
- Code Related Operation Keys (only in browsers)
Cursor Movement Keys
These are usually CTRL-key combinations.
- CTRL-e / End: Move to End
Moves the text cursor to the end of the line.
If your keyboard has a key named "End", that has the same function.
- Pos1: Move to Begin
Moves the text cursor to the beginning of the line.
- CTRL-w: Next Word
Moves the text cursor to the beginning of the next word.
What exactly makes a "word" may depend on the contents, and the editor's setting.
For example, whether the "underline" character is treated like part of an
alphanumeric word, or not can be controlled by a toggle in the Launcher's settings dialog.
- CTRL-W (= CTRL-SHIFT-w): End of Word
Moves the text cursor to the end of the current or next word.
If the cursor is currently within a word, it is moved to the end of it.
If the cursor is already at the end of a word, it is moved to the end of the next word.
- CTRL-g: Goto Line
Opens a dialog asking for a line number.
Positions the cursor into that line.
- CTRL-f: Search
Opens a text search & replace dialog box.
Selection Keys
These are usually ALT-key combinations, except on systems where these
key combinations are already used by the window manager.
In this case, other (usually CTRL-key) combinations are used;
take a look at the keyboard map in the settings dialog or inspect the
"keyboard.rc
" file for your concrete setting..
- ALT-w: Select Word
If there is currently no selection,
the word under the cursor is selected. If there is already a word selected,
the next word is selected.
Warning: on OSX, this key combination is by default mapped to
the window manager's "Close Window" operation. Don't use it on a Mac.
- ALT-l: Select Line
If there is currently no selection,
the whole cursor line selected. Otherwise, the selection is expanded to include the
next line. Pressing Alt-l multiple times, allows for quick selection of a block of
lines.
- ALT-f: Forward Search
If there is a selection,
search forward for the next occurence of that string.
Typically this is used to search for words in the text.
If there is no selection, previously searched string is searched again.
See also ALT-s which opens a search box.
- ALT-b: Backward Search
If there is a selection,
search backward for the previous occurence of that string.
Typically used to search for words in the text.
If there is no selection, previously searched string is searched again.
See also ALT-s which opens a search box.
- ALT-s: Search
Opens a search dialog box, to enter a string
and possibly change the search behavior.
Operation Keys
- CTRL-c, CTRL-x, CTRL-v: Copy, Cut and Paste
As usual.
- CTRL-V (that is CTRL-SHIFT-v): Paste Previous
Presents previously copied or cut text fragments in a dialog.
Lets you paste one of them.
- CTRL-z: Undo
Undo the last edit change. An arbitrary number of operations
can be undone, up to the original contents.
- CTRL-y: Redo
Oops, if you undid one too many.
- F3 / F4: Comment / Uncomment
Comment / uncomment the selected text.
If there is no selection, the current cursor line is affected.
On some machines, these functions are found shifted to the right
on F4/F5, because F3 is used by the window system.
- F9 / F10: Indent / Undent by Tab
Indent / undent the selected line(s) or the cursor line by the
tab space setting (see user preferences).
By default, Smalltalk/X uses multiples of 4 tab columns.
- F11 / F12: Indent / Undent by 1
As above, but inserts/removes a single space.
- F8: Again
Repeat the previous cut or replace operation.
Thus to replace some text at multiple places in the document,
select the word, type the replacement, then press Again.
Repeat Again until the end of the document is reached,
or select the "Again For All" menu function.
- CTRL-s: Save/Accept
Accept modifications / save contents. The details of this operation depend on
the context in which the editor operates: in a system browser, changed code is compiled
and installed. In a file browser, the changed contents is saved in the edited file.
In an inspector's right panel, a changed value is stored in the inspected object.
- ALT-a: Save/Accept
An alternative key combination. This is recognized for backward compatibility,
to keep old fashioned ST/X users happy.
Code Related Operation Keys
These are highlevel command keys, which are available in
editors which show code (eg. in Code Browsers or Workspaces).
- F2: Rename
Rename the selected method argument or method local
within the edited method.
The changed method is also accepted (saved).
This operation can be undone via the top-level "Operations" menu.
- CTRL-d: DoIt
Evaluate the selected text as a Smalltalk expression.
If there is no current selection, the current cursor line is taken.
- CTRL-p: PrintIt
Evaluate the selected text as a Smalltalk expression
and paste the printString of the result.
If there is no current selection, the current cursor line is taken.
- CTRL-q: InspectIt
Evaluate the selected text as a Smalltalk expression
and open an inspector on the result.
If there is no current selection, the current cursor line is taken.
- CTRL-B: (that is CTRL-SHIFT-b) Browse
Evaluate the selected text as a Smalltalk expression
(typically, this will be the name of a class, as already written in the code),
and open another browser on that class.
- CTRL-I: (that is CTRL-SHIFT-i) Implementors
Extract the message selector from the selected text
and open another browser on implementors of that message.
ST/X is tolerant w.r.t. the syntax of the selection,
and tries hard to make it reasonable (meaning: you can select
a partial or syntactically incorrect text fragment,
and most of the time, it will do the right thing)
The code view performs syntax coloring as you type.
A number of different coloring styles are availabe
and can be customized via the Launcher's
"System" - "Settings - ""Tools"
- "Editor" - "Syntax Colors" dialog.
If enabled in the Launcher's settings dialog,
the editor offers code completions, either on the fly, "as you type",
or initiated by a key ("Tab" or "Ctrl").
When "as you type" completion is enabled, a floating window
presents plausible completions. This list is updated as you
type more or delete characters by backspacing.
The window is closed by pressing "Esc".
To select a completion, first navigate the list using the
"CursorUp" or "CursorDown" key, then press "Return".
Some users find it irritating that the cursor- and return keys are intercepted
this way. Those may check the "Shift/Control to Navigate in Completion" checkbox in the Launcher's
settings. If set, reguler key presses are handled as usual and
to navigate the completion list, press "Shift" (or "Ctrl")-"CursorKey"
and "Shift-Return".
The setting also includes check boxes named
"Tab" or "Ctrl"-completion.
If checked, the completion list appears when that key is pressed.
Snippets are little code fragments which appear often
in source code.
A predefined (but customizable) list of abbreviations is
defined in the Workspace class.
The snippet to be inserted is determined by the character(s)
before the cursor.
If a code completion list is presented, any applyable
snippet is also appended to this list (and can thus be easily
selected via CursorUp-Return.
The behavior can be adjusted via the Launcher's
"System"-"Settings"-"Tools"-"Editor" dialog.
The settings are kept in "~/.smalltalk/settings.stx
"
(although it is not good idea to edit it, as it will be overwritten when
the settings are saved).
The keyboard map is read upon startup from the "keyboard.rc
" file.
Advanced users may edit this and adjust to personal preferences.
Hint: there is no need to modify the system's default "keyboard.rc
" file,
which might be installed in a read-only folder or shared among multiple users.
Instead, copy the file to your "~/.smalltalk
" folder and edit that file.
This folder will be searched before the system folder upon startup.
The Cursor behavior of the editor can be configured to one of two modes:
- Rand-editor Mode (*)
- vi/emacs/st80-editor Mode
In "Rand-editor" mode, the window behaves like a piece of paper,
where the text-cursor can be positioned wherever you like,
simply by clicking there.
If required, spaces are inserted.
In "vi-editor" mode, the cursor can only positioned to a place after an actual character.
If you click to the right of the last character in a line, the cursor will be placed
right after the last character in that line.
If you click below the last line, it will be positioned at the end of the text.
Non-programmers usually find the "Rand-editor" behavior more natural,
whereas most programmers are used to the "unnatural" vi/emacs behavior.
You can change this setting in the Launcher's settings dialog, under
"Tools" - "Editor" - "ST80 cursor behavior at end of line".
(*) the "Rand-editor, known as e" was a much advanced wysiwyg editor for glass-tube displays.
It was quite popular in the 80's. (http://www.rand.org/pubs/notes/2006/N2239-1.pdf)
By default, ST/X uses tabs of 4 (i.e. at positions 1, 5, 9, ...) for indentation,
which gives a good compromise between line-length and readability
(tabs of 8 typically lead to very long lines, which make the code harder to
read as you might have to scroll horizontally).
Notice, that the tab setting only affects the cursor behavior in the editor.
Externally (i.e. in the file), tabs are always assumed to be in multiples of 8.
When reading a file, leading tabs are converted, and vice versa, when writing
files, leading spaces are converted to tabs in multiples of 8.
Copyright © 1995-2018 Claus Gittinger Development & Consulting, all rights reserved
<cg at exept.de>
Doc $Revision: 1.21 $ $Date: 2021/03/13 18:24:52 $