diff --git a/doc/api/repl.md b/doc/api/repl.md index c384ebf1391303..6475de353d7583 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -27,7 +27,8 @@ result. Input and output may be from `stdin` and `stdout`, respectively, or may be connected to any Node.js [stream][]. Instances of [`repl.REPLServer`][] support automatic completion of inputs, -completion preview, simplistic Emacs-style line editing, multi-line inputs, +completion preview, inline syntax highlighting, automatic indentation, +function signature hints, simplistic Emacs-style line editing, multi-line inputs, [ZSH][]-like reverse-i-search, [ZSH][]-like substring-based history search, ANSI-styled output, saving and restoring current REPL session state, error recovery, and customizable evaluation functions. Terminals that do not support @@ -232,6 +233,52 @@ undefined undefined ``` +### Syntax highlighting + + + +When `useColors` is `true`, the REPL highlights +JavaScript input using the following color scheme: + +* **Keywords** (`const`, `let`, `function`, `if`, `return`, etc.): Magenta +* **Strings** (single-quoted, double-quoted, and template literals): Green +* **Numbers**: Yellow +* **Boolean literals** (`true`, `false`), `null`, `undefined`, `NaN`, + `Infinity`: Yellow +* **Regular expressions**: Red +* **Comments** (line and block): Gray + +Syntax highlighting is applied only to the display; the internal `line` +property remains plain text. Highlighting can be disabled by passing +`syntaxHighlighting: false` to [`repl.start()`][]. + +### Auto-indentation + + + +When entering +multi-line input (e.g., a function body or an object literal), the REPL +automatically indents continuation lines based on the current nesting +depth of braces (`{}`), brackets (`[]`), and parentheses (`()`). The REPL +uses 2-space indentation following the Node.js coding convention. + +### Function signature hints + + + +When the user +types a function name followed by `(`, the REPL displays the function's +parameter list as a dimmed hint below the input line. This uses the V8 +inspector protocol to safely extract function signatures without side +effects. Signature hints require the `preview` option to be enabled and +the inspector to be available. + ### Reverse-i-search