From 0781e7ed5aa5f55b2d45a55bc772d67cf59f4812 Mon Sep 17 00:00:00 2001 From: Mohamed Mohsen Date: Wed, 13 May 2026 12:38:26 +0300 Subject: [PATCH] docs: improve Node REPL dot commands explanation - Group `.clear` and `.break` together as equivalent in default REPL - Simplify descriptions of dot commands - Clarify that `.clear` only resets context in custom programmatic REPL Signed-off-by: Mohamed Mohsen --- .../how-to-use-the-nodejs-repl.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/pages/command-line/how-to-use-the-nodejs-repl.md b/pages/command-line/how-to-use-the-nodejs-repl.md index 7b4a19c..57719aa 100644 --- a/pages/command-line/how-to-use-the-nodejs-repl.md +++ b/pages/command-line/how-to-use-the-nodejs-repl.md @@ -87,13 +87,12 @@ If you press the `up` arrow key, you will get access to the history of the previ The REPL has some special commands, all starting with a dot `.`. They are -- `.help`: shows the dot commands help -- `.editor`: enables editor mode, to write multiline JavaScript code with ease. Once you are in this mode, enter ctrl-D to run the code you wrote. -- `.break`: when inputting a multi-line expression, entering the .break command will abort further input. Same as pressing ctrl-C. -- `.clear`: resets the REPL context to an empty object and clears any multi-line expression currently being input. -- `.load`: loads a JavaScript file, relative to the current working directory -- `.save`: saves all you entered in the REPL session to a file (specify the filename) -- `.exit`: exits the repl (same as pressing ctrl-C two times) +- `.help`: shows the dot commands help. +- `.editor`: enters editor mode, to write multiline JavaScript code. +- `.break` / `.clear`: exits multi-line code like functions. same as pressing ctrl-C. +- `.load`: loads a JavaScript file, relative to the current working directory. +- `.save`: saves all commands you entered in the session to a file. +- `.exit`: exits the REPL (same as pressing ctrl-C two times). The REPL knows when you are typing a multi-line statement without the need to invoke `.editor`. @@ -112,6 +111,12 @@ and you press `enter`, the REPL will go to a new line that starts with 3 dots, i If you type `.break` at the end of a line, the multiline mode will stop and the statement will not be executed. +`.clear` clear the whole REPL context like restarting the session only in a custom REPL created programmatically: + +```console +require('repl').start(); +``` + ### Run REPL from JavaScript file We can import the REPL in a JavaScript file using `repl`.