Configure VS Code output window for python to jump to last line of output window? - visual-studio-code

I am sorry if the question doesn't make sense, I didn't really know how to phrase it properly.
What I am trying to achieve is similar to how it works in the command prompt when running a python file. When I run a python file from the command prompt, the command prompt window will jump to the last outputted line during the running of the program, so what is currently being outputted is always visible. However in my current VS Code set up, the output window will not jump to the last line as it is printed, and I have to scroll through the output window to see what is happening with the program.
I am currently using the latest version of VS Code and using the code-runner extension as well. Please let me know if what I am asking does not really make sense.
Thanks

As far as I understand your question, I would like to answer it.
To Auto-Scroll to the last output, you can just click on the Lock Icon near the Clear Console icon.

Related

VS Code terminal showing ERROR on every line with oh-my-posh

My terminal in VS Code has since the previous update shown the word ERROR on every single line. I have installed oh-my-posh a little while back to make the terminal more pleasant to look at and give me some basic information.
Does anyone know where to look, to find the source of the error message? Tyvm :)
Update
Noticed something different when running echo $ as suggested by #kamen-minkov
When I booted Ubuntu up again and my VS Code opened from the previous state it was in the ERROR label was gone:
However. When I opened up a new tab it returned:
The only difference I can notice between the two is that there is a little, unfilled, circle/dot on the left side of the newly opened tab and not the one that opened up with VS Code. Is it some sort of debugger marking or something else? Could it be the source of the problem?
Apparently it's the Shell Integration decorations that's causing the hazards..
// settings.json
"terminal.integrated.shellIntegration.enabled": false,
"terminal.integrated.shellIntegration.decorationsEnabled": "never",
disable these settings and oh-my-posh error label will be gone :)

Powershell ISE addon working when using GUI menu but not when using its assigned custom keyboard shortcut

I still use the ISE on occasion and decided to attempt a custom ISE addon that emulates VS Code's Delete Line Ctrl+Shift+K keyboard shortcut. For the moment, this rough draft doesn't delete multiple lines if selected (that functionality will be added later), only the line the cursor is on:
[void]$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Delete Line", {
$psise.CurrentFile.Editor.SelectCaretLine()
[System.Windows.Forms.SendKeys]::SendWait("{DEL}")
[System.Windows.Forms.SendKeys]::SendWait("{DEL}")
}, "Ctrl+Shift+K")
What I discovered is that this runs as intended when using clicking on the ISE's menu (Add-ons > Delete Line) but not when using its assigned keyboard shortcut (Ctrl+Shift+K). Using the keyboard shortcut runs everything I've put in the code block thus far except the SendWait() method(s).The result when using the keyboard shortcut is what you would expect $psise.CurrentFile.Editor.SelectCaretLine() to do - highlight the line that the cursor is currently on - it just doesn't send 'Delete' twice. The console output is identical when using either method (GUI vs keyboard shortcut). I've run into some goofy things when using Winforms classes within the ISE, but the difference in behavior between using the ISE Add-ons menu vs keyboard shortcut is new to me. I've googled for PowerShell ISE SendKeys and ISE SendWait etc and have come up empty.I'm open to suggestions on a better method (regex, pinvoke/embedded Win32, etc) but am hoping to gain some insight into what's happening under the hood within ISE.I know, I know - I already use VS Code for a lot and ISE is dying, but this has me curious now and I'd like to know either how to fix this or at least understand why the SendWait method isn't playing well with the ISE.Any help is much appreciated!
*** removing my previous answer, since you had issues with the approach.***
Refactoring to just this, fully tested/validated for what you say you want. I'd still work to avoid Send-Keys, unless there is no other option.
Function Delete-Line
{
$psISE.CurrentFile.Editor.SelectCaretLine()
# Pause the allow for Send-Keys to work for HotKey use
Start-Sleep -Seconds 1
[System.Windows.Forms.SendKeys]::SendWait('{DEL}')
}
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add("Delete Current Line", {Delete-Line}, 'Ctrl+Shift+K')
You of course can adjust that time to fit your response time. Say, using milliseconds vs seconds. This timing is not absolute with Send-Keys. Each machine you use this on may need a time adjustment. Hence the reason to use another more efficient approach.

How to make the beginning of directory on the new line from the end of terminal in VS Code

In the first screenshot is VS Code on my PC and the second one is from my laptop.
As you can see, I'm using the same code in both screenshots, but in img1, the terminal output ("3") is on the different line with the file directory unlike the second one which stick right into it.
I don't know how to fix this problem, if anyone know how to change this please give me an instruction
first screenshot
second screenshot

VSCode displays source code again in interactive window

A question from a newbie here: when I run some python code in VSCode, there is always a display of source code in the interactive window. Thus I have to scroll all the way down before I can see the output. That makes the debug quite troublesome.
Please see the screenshot above. The code was displayed in the interactive window despite the editor just at left side over there. Any way to have VSCode, or maybe Jupyter extension, go directly to the output? (in my case starting from the 'Training Dataset shape......')

Why does file have to be saved prior to running?

In MATLAB, why does the file have to be saved prior to running ?
I often try quick snippets of code, which I could also easily run also on the Command Window line by line. So, why when I run them through the editor, I have to save them first ?
Can this behaviour be changed, maybe ?
You can use cell mode in the editor placing %% before your code. See also Cell menu in the editor. Once you create cells, you can run them one by one pressing Ctrl-Enter. You don't need to save the file. However you cannot use editor's debugging features (breakpoints, etc).
Video tutorial
my guess would be that when you run your program, the matlab interpreter run it from the disk and not from the IDE buffer. so if you don't save the file it wouldn't run the correct code.