Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: document readline keybindings #20825

Closed
Closed
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 104 additions & 1 deletion doc/api/readline.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ added: v0.1.98

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

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

Expand Down Expand Up @@ -527,11 +528,113 @@ rl.on('line', (line) => {
});
```

## TTY keybindings

<table>
<tr>
<th>Keybindings</th>
<th>Description</th>
</tr>
<tr>
<td><code>ctrl</code> + <code>shift</code> + <code>backspace</code></td>
<td>Delete line left</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not work on Windows

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not work on WSL

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not work on macOS.

</tr>
<tr>
<td><code>ctrl</code> + <code>shift</code> + <code>delete</code></td>
<td>Delete line right</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not work on WSL

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not work on macOS.

</tr>
<tr>
<td><code>ctrl</code> + <code>c</code></td>
<td>Emit SIGINT</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>h</code></td>
<td>Delete left</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>d</code></td>
<td>Delete right or EOF</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>u</code></td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Windows this deletes entire line.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On WSL also

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also on Liux

<td>Delete from current to line start</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>k</code></td>
<td>Delete from current to end of line</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>a</code></td>
<td>Go to start of line</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>e</code></td>
<td>Go to to end of line</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>b</code></td>
<td>Back one character</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>f</code></td>
<td>Forward one character</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>l</code></td>
<td>Clear screen</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>n</code></td>
<td>Next history item</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>p</code></td>
<td>Previous history item</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>z</code></td>
<td>Moves running process into background. Type <code>fg</code> and press <code>enter</code> to return.</td>
</tr>
<tr>
<td><code>ctrl</code> + <code>w</code> &nbsp; or &nbsp; <code>ctrl</code> + <code>backspace</code></td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these &nbsp; intended here and below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah! added them for more spacing, but removing for now.

<td>Delete backwards to a word boundary</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ctrl + Backspace does not work on Windows

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meta + Backspace deletes words on Windows

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also does not work on WSL

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also not on Linux (ctrl+backspace)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctrl+w works on macOS but cntrl+backspace seems to delete forward to a word boundary?

</tr>
<tr>
<td><code>ctrl</code> + <code>delete</code></td>
<td>Delete forward to a word boundary</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not work on WSL

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not work on macOS

</tr>
<tr>
<td><code>ctrl</code> + <code>left</code></td>
<td>Word left </td>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On macOS, it's command+option+left. ctrl+left does not work.

</tr>
<tr>
<td><code>ctrl</code> + <code>right</code></td>
<td>Word right</td>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On macOS, it's command+option+right. ctrl+right does not work.

</tr>
<tr>
<td><code>meta</code> + <code>b</code></td>
<td>Word left</td>
</tr>
<tr>
<td><code>meta</code> + <code>f</code></td>
<td>Word right</td>
</tr>
<tr>
<td><code>meta</code> + <code>d</code> &nbsp; or &nbsp; <code>meta</code> + <code>delete</code></td>
<td>Delete word right</td>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meta + Delete does not work on Windows

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also on WSL

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On macOS, meta+d works, but meta+delete does a delete word left rather than right.

</tr>
<tr>
<td><code>meta</code> + <code>backspace</code></td>
<td>Delete word left </td>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does not work on macOS.

</tr>
</table>

[`'SIGCONT'`]: readline.html#readline_event_sigcont
[`'SIGTSTP'`]: readline.html#readline_event_sigtstp
[`process.stdin`]: process.html#process_process_stdin
[`process.stdout`]: process.html#process_process_stdout
[Readable]: stream.html#stream_readable_streams
[TTY]: tty.html
[TTY keybindings]: #readline_tty_keybindings
[Writable]: stream.html#stream_writable_streams
[reading files]: #readline_example_read_file_stream_line_by_line
3 changes: 3 additions & 0 deletions doc/api/repl.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ The following key combinations in the REPL have these special effects:
variables. When pressed while entering other input, displays relevant
autocompletion options.

For a full list of special keys, refer to [TTY keybindings][].

### Default Evaluation

By default, all instances of `repl.REPLServer` use an evaluation function that
Expand Down Expand Up @@ -632,5 +634,6 @@ For an example of running a REPL instance over [curl(1)][], see:
[`readline.InterfaceCompleter`]: readline.html#readline_use_of_the_completer_function
[`readline.Interface`]: readline.html#readline_class_interface
[`util.inspect()`]: util.html#util_util_inspect_object_options
[TTY keybindings]: readline.html#readline_tty_keybindings
[curl(1)]: https://curl.haxx.se/docs/manpage.html
[stream]: stream.html