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
Related
When opening a Python file in vscode, I see an overlay in the upper right corner of the window that allows me to directly run the program:
Where does this overlay comes from?
from an extension specific to Python?
from something that leverage tasks and allows for such display?
something else?
I am asking because it would be great to have such a shortcut in other programming languages (Go in my case) to quickly launch (something, usually to run a program)
This functionality comes from the ms-python.python extension.
You can verify for yourself: Disable the extension, then do the required IDE reload, then observe that that button is gone. Then enable the extension and observe that it is back.
There's even a corresponding command that you can use in the command palette: Straight from the extension docs:
Python: Run Python File in Terminal
Runs the active Python file in the VS Code terminal. You can also run a Python file by right-clicking on the file and selecting Run Python File in Terminal.
Note: Since you mentioned:
I am asking because it would be great to have such a shortcut in other programming languages (Go in my case) to quickly launch (something, usually to run a program)
Since this is functionality provided by an extension, you're "at the mercy" of whatever the extension devlopers actually want to implement, and whether such a feature actually makes sense for a given language.
Such a "run file" button would very natural for languages that lend themselves toward scripting, but less so for languages geared toward larger projects where it's not statistically normal for a file to "have a main function".
I used to use the Atom code editor and one of the features I liked about this editor was that when I executed python code it would bring up an external CMD window where I would interact with the code, if input was required, and receive the results.
I have moved to VS Code as Atom is no longer supported and I have looked on here and with Google, but I do not seem to be able to get VS Code to behave in this fashion :(
I am wondering if any of the folks on here with more experience with VS code can advise if what I am looking to do is possible or do I just have to suck it up and use the integrated terminal/output panes at the bottom of the window?
Any advise would be very much appreciated.
I have tried in the "Configure Terminal Settings" to change from Integrated to External, but this has made no difference.
I am trying to make terminal interference minimal by removing element I don't need. I am beginner in programming.
I want to remove the highlighted part.:
I am using coderunner and C/C++ Compile Run. I lloked for this on google and but Code-runner: Clear previous output, it does not work for me. Also is there any way I can clear terminal automatically when running the code using ctrl+alt+N instead doing it manually?
If I can't do this in powershell is there any other shell which give this functionality?
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.
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.