From c72fff6711f2157add405cb606a27224e0cda0a0 Mon Sep 17 00:00:00 2001 From: Harshitha KP Date: Tue, 7 Jan 2020 07:37:42 -0500 Subject: [PATCH] doc: document readline key bindings This documents all readline key bindings. It is a rework of https://github.com/nodejs/node/pull/20825 PR-URL: https://github.com/nodejs/node/pull/31256 Fixes: https://github.com/nodejs/node/issues/20814 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- doc/api/readline.md | 129 +++++++++++++++++++++++++++++++++++++++++++- doc/api/repl.md | 5 ++ 2 files changed, 133 insertions(+), 1 deletion(-) diff --git a/doc/api/readline.md b/doc/api/readline.md index 4c13304888fe21..3711120597d053 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -293,7 +293,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. @@ -722,6 +723,131 @@ const { createInterface } = require('readline'); })(); ``` +## TTY keybindings + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KeybindingsDescriptionNotes
ctrl + shift + backspaceDelete line leftDoesn't work on Linux, Mac and Windows
ctrl + shift + deleteDelete line rightDoesn't work on Linux and Mac
ctrl + cEmit SIGINT or close the readline instance
ctrl + hDelete left
ctrl + dDelete right or close the readline instance in case the current line is empty / EOFDoesn't work on Windows
ctrl + uDelete from the current position to the line start
ctrl + kDelete from the current position to the end of line
ctrl + aGo to start of line
ctrl + eGo to to end of line
ctrl + bBack one character
ctrl + fForward one character
ctrl + lClear screen
ctrl + nNext history item
ctrl + pPrevious history item
ctrl + zMoves running process into background. Type + fg and press enter + to return.Doesn't work on Windows
ctrl + w or ctrl + + backspaceDelete backwards to a word boundaryctrl + backspace Doesn't + work as expected on Windows
ctrl + deleteDelete forward to a word boundaryDoesn't work on Mac
ctrl + left or + meta + bWord leftctrl + left Doesn't work + on Mac
ctrl + right or + meta + fWord rightctrl + right Doesn't work + on Mac
meta + d or meta + + deleteDelete word rightmeta + delete Doesn't work + on windows
meta + backspaceDelete word leftDoesn't work on Mac
+ [`'SIGCONT'`]: readline.html#readline_event_sigcont [`'SIGTSTP'`]: readline.html#readline_event_sigtstp [`'line'`]: #readline_event_line @@ -731,5 +857,6 @@ const { createInterface } = require('readline'); [`rl.close()`]: #readline_rl_close [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 diff --git a/doc/api/repl.md b/doc/api/repl.md index 8305b1d2c920ca..3e4894befc7075 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -66,6 +66,9 @@ The following key combinations in the REPL have these special effects: variables. When pressed while entering other input, displays relevant autocompletion options. +For key bindings related to the reverse-i-search, see [`reverse-i-search`][]. +For all other key bindings, see [TTY keybindings][]. + ### Default Evaluation By default, all instances of [`repl.REPLServer`][] use an evaluation function @@ -709,5 +712,7 @@ For an example of running a REPL instance over [curl(1)][], see: [`repl.ReplServer`]: #repl_class_replserver [`repl.start()`]: #repl_repl_start_options [`util.inspect()`]: util.html#util_util_inspect_object_options +[`reverse-i-search`]: #repl_reverse_i_search +[TTY keybindings]: readline.html#readline_tty_keybindings [curl(1)]: https://curl.haxx.se/docs/manpage.html [stream]: stream.html