SLED(1) General Commands Manual SLED(1)

sledSimple text editor

sled -h | --help | -V | --full-version | -v | --version

sled filename

sled is a simple text editor with a terminal UI.

, --help
Show option summary.
, --full-version
Show full version information: like -v, followed by copyright notice and defines set in config.h.
, --version
Show version information: program version and source git repository commit date.

sled has four modes of operation.

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 behaves more like vi(1): characters like h, j, k, l no longer insert themselves but execute commands (in this case movement commands).
This is the same as insert mode, except that newly inserted characters replace the existing ones instead of being inserted among them.
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: , and

These are active in all modes, and are as follows:

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

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.

In Command mode, the following vi-like keys are in effect:

/ 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

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 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.

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:

File is a binary file and open_binary is set to zero.
File is not a regular file.

Strahinya Radich <sr@strahinja.org>, 2022-2024

Bugs can be reported using the ticket tracker at: https://todo.sr.ht/~strahinja/sled

  • 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.
November 2, 2024 OpenBSD 7.6