Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b9aca78

Browse filesBrowse files
HarshithaKPMylesBorins
authored andcommitted
doc: document readline key bindings
This documents all readline key bindings. It is a rework of #20825 PR-URL: #31256 Fixes: #20814 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent d04118f commit b9aca78
Copy full SHA for b9aca78

File tree

Expand file treeCollapse file tree

2 files changed

+133
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+133
-1
lines changed
Open diff view settings
Collapse file

‎doc/api/readline.md‎

Copy file name to clipboardExpand all lines: doc/api/readline.md
+128-1Lines changed: 128 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ added: v0.1.98
293293

294294
The `rl.write()` method will write either `data` or a key sequence identified
295295
by `key` to the `output`. The `key` argument is supported only if `output` is
296-
a [TTY][] text terminal.
296+
a [TTY][] text terminal. See [TTY keybindings][] for a list of key
297+
combinations.
297298

298299
If `key` is specified, `data` is ignored.
299300

@@ -722,6 +723,131 @@ const { createInterface } = require('readline');
722723
})();
723724
```
724725

726+
## TTY keybindings
727+
728+
<table>
729+
<tr>
730+
<th>Keybindings</th>
731+
<th>Description</th>
732+
<th>Notes</th>
733+
</tr>
734+
<tr>
735+
<td><code>ctrl</code> + <code>shift</code> + <code>backspace</code></td>
736+
<td>Delete line left</td>
737+
<td>Doesn't work on Linux, Mac and Windows</td>
738+
</tr>
739+
<tr>
740+
<td><code>ctrl</code> + <code>shift</code> + <code>delete</code></td>
741+
<td>Delete line right</td>
742+
<td>Doesn't work on Linux and Mac</td>
743+
</tr>
744+
<tr>
745+
<td><code>ctrl</code> + <code>c</code></td>
746+
<td>Emit <code>SIGINT</code> or close the readline instance</td>
747+
<td></td>
748+
</tr>
749+
<tr>
750+
<td><code>ctrl</code> + <code>h</code></td>
751+
<td>Delete left</td>
752+
<td></td>
753+
</tr>
754+
<tr>
755+
<td><code>ctrl</code> + <code>d</code></td>
756+
<td>Delete right or close the readline instance in case the current line is empty / EOF</td>
757+
<td>Doesn't work on Windows</td>
758+
</tr>
759+
<tr>
760+
<td><code>ctrl</code> + <code>u</code></td>
761+
<td>Delete from the current position to the line start</td>
762+
<td></td>
763+
</tr>
764+
<tr>
765+
<td><code>ctrl</code> + <code>k</code></td>
766+
<td>Delete from the current position to the end of line</td>
767+
<td></td>
768+
</tr>
769+
<tr>
770+
<td><code>ctrl</code> + <code>a</code></td>
771+
<td>Go to start of line</td>
772+
<td></td>
773+
</tr>
774+
<tr>
775+
<td><code>ctrl</code> + <code>e</code></td>
776+
<td>Go to to end of line</td>
777+
<td></td>
778+
</tr>
779+
<tr>
780+
<td><code>ctrl</code> + <code>b</code></td>
781+
<td>Back one character</td>
782+
<td></td>
783+
</tr>
784+
<tr>
785+
<td><code>ctrl</code> + <code>f</code></td>
786+
<td>Forward one character</td>
787+
<td></td>
788+
</tr>
789+
<tr>
790+
<td><code>ctrl</code> + <code>l</code></td>
791+
<td>Clear screen</td>
792+
<td></td>
793+
</tr>
794+
<tr>
795+
<td><code>ctrl</code> + <code>n</code></td>
796+
<td>Next history item</td>
797+
<td></td>
798+
</tr>
799+
<tr>
800+
<td><code>ctrl</code> + <code>p</code></td>
801+
<td>Previous history item</td>
802+
<td></td>
803+
</tr>
804+
<tr>
805+
<td><code>ctrl</code> + <code>z</code></td>
806+
<td>Moves running process into background. Type
807+
<code>fg</code> and press <code>enter</code>
808+
to return.</td>
809+
<td>Doesn't work on Windows</td>
810+
</tr>
811+
<tr>
812+
<td><code>ctrl</code> + <code>w</code> or <code>ctrl</code>
813+
+ <code>backspace</code></td>
814+
<td>Delete backwards to a word boundary</td>
815+
<td><code>ctrl</code> + <code>backspace</code> Doesn't
816+
work as expected on Windows</td>
817+
</tr>
818+
<tr>
819+
<td><code>ctrl</code> + <code>delete</code></td>
820+
<td>Delete forward to a word boundary</td>
821+
<td>Doesn't work on Mac</td>
822+
</tr>
823+
<tr>
824+
<td><code>ctrl</code> + <code>left</code> or
825+
<code>meta</code> + <code>b</code></td>
826+
<td>Word left</td>
827+
<td><code>ctrl</code> + <code>left</code> Doesn't work
828+
on Mac</td>
829+
</tr>
830+
<tr>
831+
<td><code>ctrl</code> + <code>right</code> or
832+
<code>meta</code> + <code>f</code></td>
833+
<td>Word right</td>
834+
<td><code>ctrl</code> + <code>right</code> Doesn't work
835+
on Mac</td>
836+
</tr>
837+
<tr>
838+
<td><code>meta</code> + <code>d</code> or <code>meta</code>
839+
+ <code>delete</code></td>
840+
<td>Delete word right</td>
841+
<td><code>meta</code> + <code>delete</code> Doesn't work
842+
on windows</td>
843+
</tr>
844+
<tr>
845+
<td><code>meta</code> + <code>backspace</code></td>
846+
<td>Delete word left</td>
847+
<td>Doesn't work on Mac</td>
848+
</tr>
849+
</table>
850+
725851
[`'SIGCONT'`]: readline.html#readline_event_sigcont
726852
[`'SIGTSTP'`]: readline.html#readline_event_sigtstp
727853
[`'line'`]: #readline_event_line
@@ -731,5 +857,6 @@ const { createInterface } = require('readline');
731857
[`rl.close()`]: #readline_rl_close
732858
[Readable]: stream.html#stream_readable_streams
733859
[TTY]: tty.html
860+
[TTY keybindings]: #readline_tty_keybindings
734861
[Writable]: stream.html#stream_writable_streams
735862
[reading files]: #readline_example_read_file_stream_line_by_line
Collapse file

‎doc/api/repl.md‎

Copy file name to clipboardExpand all lines: doc/api/repl.md
+5Lines changed: 5 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ The following key combinations in the REPL have these special effects:
6969
variables. When pressed while entering other input, displays relevant
7070
autocompletion options.
7171

72+
For key bindings related to the reverse-i-search, see [`reverse-i-search`][].
73+
For all other key bindings, see [TTY keybindings][].
74+
7275
### Default Evaluation
7376

7477
By default, all instances of [`repl.REPLServer`][] use an evaluation function
@@ -738,5 +741,7 @@ For an example of running a REPL instance over [curl(1)][], see:
738741
[`repl.ReplServer`]: #repl_class_replserver
739742
[`repl.start()`]: #repl_repl_start_options
740743
[`util.inspect()`]: util.html#util_util_inspect_object_options
744+
[`reverse-i-search`]: #repl_reverse_i_search
745+
[TTY keybindings]: readline.html#readline_tty_keybindings
741746
[curl(1)]: https://curl.haxx.se/docs/manpage.html
742747
[stream]: stream.html

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.