edlin(3)
π edlin(3) β Erlang Module Definition π
okay bestie, gather round, because this one is literally the line and input interpreter for the Erlang shell π«Ά and yes it's as iconic as it sounds.
β¨ NAME β¨
edlin β the line and input interpretter for the erlang shell. π
(yes, "interpretter" with two t's, that's how it's written, no I will not be fixing it, we respect the source π )
πΈ DESCRIPTION πΈ
so like. this module reads input, handles any escape sequences that have been configured via edlin_key, and then outputs action requests. and those action requests? they get handled either by the group modules or the user_drv. that's the whole vibe. β¨
π KEY CONFIGURATION π
ok so you CAN set up a custom key configuration that overrides the default key configuration. the way you do it is by setting the stdlib application parameter shell_keymap before Erlang is started. π«Ά
and if you want the same keymap in all Erlang shells (yes, all of them, main character consistency π) you can do that by putting a config file in your user's home directory and then setting ERL_FLAGS to load it at startup. for example:
$ cat $HOME/.erlang_keymap.config
[{stdlib,
[{shell_keymap,
#{ normal => #{ "\^[A" => clear } }
}]
}].
$ ERL_FLAGS="-config $HOME/.erlang_keymap" erl
the current keymap configuration can be fetched through edlin:keymap(). and listen β if a custom keymap or keymap file is specified, then it will be merged with the default keymap. it doesn't replace it. it's giving collaborative, not competitive π
the keymap is a map of maps where the keys in the parent map correspond to different editing modes in the shell. the valid modes currently supported are normal and search. π
the keys in the child maps are the escape sequences that are sent from the terminal when a key is pressed, and each value is a valid action as seen below. β¨οΈ
the default atom is used to specify that an action should happen when a key is pressed that does not have any mapping. typically used to exit a mode. π
See tty - A Command-Line Interface for more information about the default keymap. ngl, go read it, it's the lore.
π ACTIONS π
the commands below are the built-in action requests for switching input modes on the normal shell or navigating, or manipulating the line feed. the line feed supports multiple lines. π₯
auto_blinkβ automatically close the closest matching opening parenthesis.backward_charβ move backward one character.backward_delete_charβ delete the character behind the cursor.backward_delete_wordβ delete the word behind the cursor.backward_kill_lineβ delete all characters from the cursor to the beginning of the line and save them in the kill buffer.backward_kill_wordβ delete the word behind the cursor and save it in the kill buffer.backward_lineβ move backward one line.backward_wordβ move backward one word.beginning_of_expressionβ move to the beginning of the expression.beginning_of_lineβ move to the beginning of the line.clearβ clear the screen.clear_lineβ clear the current expression.end_of_expressionβ move to the end of the expression.end_of_lineβ move to the end of the line.forward_charβ move forward one character.forward_delete_charβ delete the character under the cursor.forward_lineβ move forward one line.forward_wordβ move forward one word.history_downβ move to the next item in the history.history_upβ move to the previous item in the history.kill_lineβ delete all characters from the cursor to the end of the line and save them in the kill buffer.kill_wordβ delete the word under the cursor and save it in the kill buffer.new_line_finishβ add a newline at the end of the line and try to evaluate the current expression.newlineβ add a newline at the cursor position.open_editorβ open the current line in an editor e.g.EDITOR="code -w"opens a buffer in vs code. > note that you need to pass a flag to the editor so that it signals the shell when you close the buffer. don't skip this part bestie, it's the whole trick π«Άredraw_lineβ redraw the current line.search_cancelβ cancel the current search.search_foundβ accept the current search result and submit it.search_quitβ accept the current search result, but edit it before submitting.searchβ enter search mode, search the history.search_downβ skip to the next line in the history that matches the current search expression.search_upβ skip to the previous line in the history that matches the current search expression.tab_expand_fullβ output all possible tab completions.tab_expand_quitβ go back to normal mode.tab_expandβ autocomplete the current word, or show 5 lines of possible completions.transpose_charβ swap the character behind the cursor with the one in front of it.transpose_wordβ swap the word behind the cursor with the one in front of it.yankβ insert the contents of the kill buffer at the cursor position.
π¦ DATA TYPES π¦
keymap()
keymap() = #{atom() => #{string() | default => atom()}}
a map of maps for each shell mode containing key, action pairs. that's it, that's the type, she's simple and she slays π
π EXPORTS π
keymap() -> keymap()
Types:
keymap() = #{atom() => #{string() | default => atom()}}
get the current keymap used in the shell. π each key in the parent map represents a shell mode e.g. normal or search. each map associated with the shell modes contains key sequences represented as strings, paired with an action, which is one of the valid actions mentioned above. β
and that's the whole page bestie, you ate it, you understood it, periodt. π
this has been brought to you by Ericsson AB, running stdlib 5.2.3.6, and it's edlin(3) β version dropped, date stamped, legacy secured. mwah πβ¨
π¦ where this page comes from
- fedora 43: erlang-stdlib 26.2.5.21-8.fc43 Β· Apache-2.0
- fedora 44: erlang-stdlib 26.2.5.18-1.fc44 Β· Apache-2.0
- fedora 44: erlang-stdlib 26.2.5.21-8.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms