Skip to content

Commands

Achilleas Kiritsakas edited this page Mar 2, 2020 · 15 revisions

Javascript REPL extension can be activated on the following file types: (.js, .ts, .coffee, .jsx, .tsx, .vue). Users that have installed the extension, if the press in vscode cmd(or ctrl) + shift + p and type "JS Repl:" in command window, they will see the list of available commands

vscode-javascript-repl list of available commands

Start in existed file

  • By pressing cmd(or ctrl) + shift + l as a shortcut or by using the command "JS Repl: Run"
  • By pressing the start indicator at the top right corner of their current editor

vscode-javascript-repl start repl in current file

  • By pressing right-click in their current editor area, and select the command "JS Repl: Run"

vscode-javascript-repl start repl by right-click

Stop

Users that have more than one different repl session can stop a specific session

  • By using the command: "JS Repl: Stop on Current File".
  • By pressing the stop indicator at the top right corner of their current editor that they want to stop

vscode-javascript-repl stop current session

  • By pressing right-click in their current editor area, and select the command "JS Repl: Stop on Current File"

vscode-javascript-repl stop repl by right-click

Stop all

Users that have more than one different repl sessions they can stop all active repl sessions by typing the command: "JS Repl: Stop for all files"

Starting a repl session with an empty file

Users can select the following commands based on the type of code that they want to test

  • "JS Repl: New Javascript File (.js)"
  • "JS Repl: New React File (.jsx)"
  • "JS Repl: New TypeScript File (.ts)"
  • "JS Repl: New TypeScript React File (.tsx)"
  • "JS Repl: New CoffeeScript File (.coffee)"

Show Value

Users can show the value of expression without to print console.log or use the special comment. They need to select the expression in their editor and run the vscode command "JS Repl: Show Value" in order to print the value in the editor and log explorer. These logged values are not permanent and after their next edit, neither are printed in their editors nor are shown in the log Explorer at the left.

Besides, if they can select and print more than one value.

Copy Value

Users can copy the return value of the desired expression by selecting the expression in their editor and after that to run the command "JS Repl: Copy Value" in vscode. If more than one expression is selected, the value of the first selected expression is saved to their clipboard.

Reveal values in log explorer

If users have log explorer active in their config file, they can inspect nested objects or arrays in the log explorer at the left. So if they run the command "JS Repl: Reveal in explorer" and the cursor position of their current editor has a printed log, the value is revealed expanded in log explorer. Users can do the same thing by pressing right-click in their current editor area and select the command "JS Repl: Reveal in explorer" in the context menu.

vscode-javascript-repl stop repl by right-click

Show logs or copy values from explorer

If users have log explorer active in their config file, they can press right-click to a value(error or log) and select from the context menu neither "JS Repl: Copy Value" or "JS Repl: Show Log".

vscode-javascript-repl log explorer context menu commands

The show log option moves their cursor position in the editor at the line of value. If the editor is closed, it will be revealed.