NAME
sled
—
Simple text editor
SYNOPSIS
sled |
-h | --help |
-V | --full-version |
-v | --version |
sled |
filename |
DESCRIPTION
sled
is a simple text editor with a
terminal UI.
-h
,--help
- Show option summary.
-V
,--full-version
- Show full version information: like
-v
, followed by copyright notice and defines set in config.h. -v
,--version
- Show version information: program version and source git repository commit date.
Modes
sled
has four modes of operation.
- Insert mode
- The initial mode which is active on startup. It behaves like one would expect from a “normal” text editor: most characters are self-inserting, arrow keys and Backspace/Delete work as expected, and so on.
- Command mode
- Command mode behaves more like vi(1): characters like h, j, k, l no longer insert themselves but execute commands (in this case movement commands).
- Overwrite mode
- This is the same as insert mode, except that newly inserted characters replace the existing ones instead of being inserted among them.
- Selection mode
- In this mode, moving around the file extends the selection, and most commands that alter text instead delete the selection and exit selection mode.
sled
additionally has three
“modal modes”, which are active as long a modal dialog is
shown on screen. They are:
help mode,
input
mode and
numerical
input mode.
Global key bindings
These are active in all modes, and are as follows:
Key | Action |
Esc | Close dialog, clear error, cancel selection |
F1 | Show help dialog |
F2 | Toggle line numbers |
F3 | Go to next found match |
S-F3 | Go to previous found match |
F4 | Show search, then replace dialog |
F7 | Show only search dialog |
Home or C-A | Go to start of line |
PgUp or C-B | Go to previous page |
Backspace | Erase character before cursor |
C-\ | Toggle command mode |
C-C | Yank to paste buffer |
Delete or C-D | Erase character under cursor |
End or C-E | Go to end of line |
Insert | Toggle overwrite |
PgDown or C-F | Go to next page |
C-J | Rewrap paragraph or selection |
C-K | Erase to end of line |
C-L | Show Go to line dialog |
C-N | Go to next found match |
C-O | Reread (reopen) file |
C-P | Go to previous found match |
C-Q | Quit |
C-R | Go to previous word |
C-S | Write (save) file |
C-Space | Toggle selection mode |
C-T | Go to next word |
C-U | Erase to start of line |
C-V | Paste from paste buffer |
C-X | Cut to paste buffer |
C-Y | Erase the entire current line |
C-Z | Suspend |
C-W | Erase previous word |
Insert and overwrite mode key bindings
In Insert mode and Overwrite mode, characters are self-inserting, and Enter inserts new line. All the global keys apply to insert mode as well. Entering overwrite mode switches back to insert mode when the overwrite mode is toggled off, even when the overwrite mode was entered from the command mode.
Command mode key bindings
In Command mode, the
following vi
-like keys are in effect:
Key | Action |
/ | Show only search dialog |
\ | Show search, then replace dialog |
: | Show Go to line dialog |
0 | Go to start of line |
$ | Go to end of line |
d | Erase the entire current line |
G | Go to last line in the file |
g | Go to first line in the file |
H | Go to first line on the screen |
h | Go to previous character |
J | Join lines in selection/line and next line |
j | Go to next line |
k | Go to previous line |
L | Go to last line on the screen |
l | Go to next character |
M | Go to middle line on the screen |
N | Go to previous found match |
n | Go to next found match |
P | Paste from paste buffer |
q | Quit |
R | Toggle overwrite mode |
r | Reread (reopen) file |
v | Toggle selection mode |
W | Go to previous word |
w | Go to next word |
X | Cut to paste buffer |
x | Erase character under cursor |
y | Yank to paste buffer |
Z | Write (save) file |
Selection mode key bindings
If Selection mode was entered from insert mode (or insert mode is activated during selection mode), typing any self-inserting character or activating key bindings which modify text, like Delete or C-K, will erase the selected text instead, and in the case of self-inserting characters, insert the character in question, exiting the selection mode.
Similar holds true when the selection mode is entered from the
command mode or the command mode is activated during the selection mode,
except that vi
-like key bindings which modify text
will have the effect on the selection.
Status line
Status line is comprised of a number of segments, by default four.
- The leftmost segment displays the current filename, with an asterisk (*) if there are any unsaved changes.
- Second segment displays the current mode.
- Third segment displays the Unicode codepoint at the position of the cursor.
- Fourth segment displays the current position within the file, in the form
[column]:[row] ([percentage of total lines]%)
- Fifth segment shows quick help.
EXIT STATUS
The sled
utility exits 0 on
success, and >0 if an error occurs.
For errors caused by the unsuccessful calls to libc functions setting errno, that value is returned as the exit status. Otherwise, the exit status is one of the following:
AUTHORS
Strahinya Radich <sr@strahinja.org>, 2022-2024
BUGS
Bugs can be reported using the ticket tracker at: https://todo.sr.ht/~strahinja/sled
Known limitations
- UTF-8 character set is assumed.
- RTL scripts are unsupported/problematic. CJK scripts should work better after v0.17, which introduced the use of wcwidth(3).
- Only one file can be edited at a time, and no additional files can be loaded at runtime. This is a design decision.
- If backup creation is enabled (
create_backups
in config.h), the directory of the edited file must be writable by the user to open the file. - Opening binary files (containing NUL bytes) can lead to an incorrectly
drawn display. This was the reason for introducing the option
open_binary
, by default set to zero.