The c4 editor is an editor inspired by, and similar to, a stripped-down version of VI.
Enable the editor using #define EDITOR
(editor.c)
There are 4 modes in the editor:
- NORMAL
- INSERT
- REPLACE
- COMMAND
Key | Action |
---|---|
[ctrl]+a | Insert tag: COMPILE |
[ctrl]+b | Insert tag: DEFINE |
[ctrl]+c | Insert tag: INTERP |
[ctrl]+d | Insert tag: COMMENT |
[ctrl]+e | Execute the current line |
[ctrl]+h | Left 1 char |
[ctrl]+i | Right 8 chars (also [tab]) |
[ctrl]+j | Down 1 line |
[ctrl]+k | Up 1 line |
[ctrl]+l | Right 1 char |
[ctrl]+q | Left 8 chars |
[ctrl]+s | Save the block to disk |
[ctrl]+x | Delete the char under the cursor |
[ctrl]+z | Delete the char to the left of the cursor |
[esc-esc] | Goto NORMAL mode |
The movement keys are similar to those in VI:
Key | Action |
---|---|
h | Left 1 char |
j | Down 1 line |
k | Up 1 line |
l | Right 1 char |
$ | Goto the end of the line |
_ | Goto the beginning of the line |
[CR] | Goto the beginning of the next line |
[SP] | Right 1 char |
1 | Set tag: COMPILE |
2 | Set tag: DEFINE |
3 | Set tag: INTERP |
4 | Set tag: COMMENT |
: | Change to COMMAND mode |
+ | Save the current block and goto the next block |
- | Save the current block and goto the previous block |
# | Redraw the screen |
a | Append: move right 1 char and change to INSERT mode (same as 'li') |
A | Append: goto the end of the line and change to INSERT mode (same as '$i') |
b | Insert a BLANK/SPACE into the current line |
B | Insert a BLANK/SPACE to the end of the block |
c | Delete the current char and change to INSERT mode (same as 'xi') |
C | Delete to the end of the line and change to INSERT mode (same as 'd$i') |
d. | Delete the char under the cursor (same as 'x') |
d$ | Delete to the end of the line |
dd | Copy the current line into the YANK buffer and delete the line |
dw | Delete the current word |
D | Delete to the end of the line (same as 'd$') |
g | Goto the top-left of the screen |
G | Goto the bottom-left of the screen |
i | Insert: change to INSERT mode |
I | Insert: goto the beginning of the line and change to INSERT mode (same as '_i') |
J | Join the current and next lines together |
n | Insert a 'new-line' (#10/$0A) into the block |
o | Insert an empty line BELOW the current line and change to INSERT mode |
O | Insert an empty line ABOVE the current line and change to INSERT mode |
p | Paste the YANK buffer into a new line BELOW the current line |
P | Paste the YANK buffer into a new line ABOVE the current line |
q | Right 8 chars |
Q | Left 8 chars |
r | Replace the char under the cursor with the next key pressed (if printable) |
R | Change to REPLACE mode |
t | Transfer current block to text file 'block-NNN.fth' |
T | Transfer text file 'block-NNN.fth' to current block |
x | Delete the char under the cursor to the end of the line |
X | Delete the char under the cursor to the end of the block |
Y | Copy the current line into the YANK buffer |
z | Delete the char to the left of the cursor (same as 'hx') |
In INSERT mode, all printable characters are inserted into the block.
Carriage-Return inserts a new line.
In REPLACE mode, all printable characters are placed into the block.
Carriage-Return moves to the beginning of the next line.
COMMAND mode is invoked when pressing ':' in NORMAL mode.
Command | Action |
---|---|
rl | ReLoad: discard all changes and reload the current block |
w | Write the current block if it has changed |
w! | Write the current block, even if it has NOT changed |
wq | Write the current block and quit (same as ':w' ':q') |
q | Quit, if the current block has NOT changed |
q! | Quit, even if the current block has changed |
![any] | Send [any] to the c4 outer interpreter |