VSCode run JavaScript file line by line like REPL - visual-studio-code

Is it possible to run JavaScript/TypeScript file opened in VSCode line by line?
Like you press something like CMD+XXX+Enter and it runs the current line or code block?
So you can play with code interactively.
P.S.
I don't want to open JS console - I want to run the code (or code snippet) from the file currently opened in Editor.
It should be stateful, you run the first line, then second etc. "Code Runner" plugin not working that way, it forgets the previous run. So you ran the first line, then try to execute the second line - and it complains about undefined variables that were defined in the first one.

VS Code doesn't has this feature built-in, but there are a lot of extensions for it. The most used is Code Runner, but there are many others. For example, Quokka.js executes code as you type and it's the ideal to know the output of some little piece of code.

The new open source VS Code extension Javascript REPL is promising.

Related

VS Code: Output is only written in Terminal Window

Im relatively new to programming and just started learning with VS Code.
When I want to output a simple line of code in VSCode in Python e.g.
print("Hello World!")
what happens is that all the output is shown in the terminal window (with a bunch of more information like base(user), the path and so on). Only in between somewhere its written "Hello World!".
How is it possible to display the output in a "clean" way?
I am using a Conda environment. No code runner extension is installed (since this behaviour was present for people who use this extension).
I read that you can add some code to your launch.json file. Where do I find that file and is that really necessary? The output then gets shown in the debugger part. Is that correct and why not in the output window? Where is this "bug" coming from? I expected the output "Hello World" to be shown in the Output window of VSCode in a clean way.
by the way I am not bound to use VSCode. But I thought to get used to a industry standard relatively early would be beneficial. If there are other recommendations feel free to add an alternative environment.
I found a solution:
install code runner
make sure "run in terminal" is unchecked
use shortcut ctrl + opt + n to run the code clean in the output window

Using Mobaxterm right-click paste, execute large blocks of pasted code one at a time?

I've been using MobaXterm for a while now, and frequently use right-click paste to execute small blocks of code at the Linux command line or in a Python interpreter. My intention is that each line should be executed one at a time, even if I paste several lines at once. This used to work fine, but recently the application behavior changed and now I have to hit enter after each line. I have checked and "Paste using right click" is checked in the terminal settings menu. Does anyone know how to change this behavior? TIA

Compile current C++ file when saving?

I'm trying to make more daily use of Visual Studio Code, but there's one feature I really miss from my existing GVim setup: I use syntastic to compile C++ source when I save the current file, and then I can jump directly to error lines in the editor.
Is there any way to set up VS Code to do something similar?
I know that I can create a tasks.json and have Ctrl+Shift+B compile the whole project, but the turnaround for that is excessive. I just want to compile the current file when saving it, and have the error list be navigable (presumably in the Problems tab).
Success criteria:
When I save a C++ file, it runs a configured g++ command, rather than build the entire project.
It should somehow parse the output from that, and make the warnings and errors easily navigable so that I can step through them with a simple keystroke. Navigation should place my cursor on the relevant line. In Visual Studio, this used to be bound to the F8 key.
VS Code is not an IDE, it is a text editor with extension support, and it cannot be treated as such. Natively, it does not have any features allowing it to parse error output from a build task and visualize it in the editor.
The linter has the ability to markup the editor when syntax errors are present, but that is all the stock linter is capable of doing. It is the only part of VS Code that has the ability to use the Problems panel and annotate the editor with syntax errors.
That said, you are able to accomplish the 1st point you require. You can set up a keybind that executes more than one command. In your case, a keybind that would save the file and then build it. Something like:
{
"key": "ctrl+shift+b",
"command": "workbench.action.files.save",
"command": "workbench.action.tasks.build"
}
in keybindings.json would save the file and then execute the default build task when you press Ctrl+Shift+B.

How to setup Julia in VS code?

I'm coming from a pure Windows Visual Studio programming background with little Linux experience. It seems possible to use VS Code to program in Julia, but I can't figure out how to get things set up correctly.
Does anybody have good example launch.json, tasks.json, or other files that can serve as an example to build from?
This would be a great thing to see in a detailed tutorial.
Here is how things work if you are using the Julia extension for VisualStudio Code.
The extension adds a bunch of new commands. They all start with "julia", so filtering by that string should show you everything you can do with the extension.
In terms of running Julia code, the extension offers only two options right now. First, you can execute a command to start a REPL. This will just show a default Julia prompt, and you can interact with it like you would with any other Julia REPL. The second is that there is also a command, triggered by Ctrl + Enter, to send either the current editor selection or the current editor line to this REPL.
There is currently no further integration offered by the Julia extension. We do plan to add debugger support in the future, at which point I would expect F5 to start the current file in the debugger, or something like that. But that functionality is probably a couple of months away.

Is there a way to force Protractor test results to display in command prompt window instead of within VS Code?

Currently, I am working on a project which has somehow started showing the test results within VS Code (instead of the separate cmd prompt window). Any way to toggle this within VS Code as part of launch.json or tasks.json? I'm clutching at straws here...
I'm beginning to think this is not configurable...
Just discovered this was part of a recent VS Code update (10.1). According to the docs, "Since the Debug Console does not support programs that need to read input from the console, the external console is still available and you can enable it by setting the attribute externalConsole to true in your launch configuration."
Add this attribute to your launch.json