skip to Main Content

I have been trying to set the vs code to run my code files only in the interactive window by default rather than producing output from the built-in terminal window. I do not wish to use keybinding for a key combo to achieve this result as it would be akin to manually selecting and running the current file in interactive mode

imageVS Code page screenshot

I have tried umpteen times to set the interactive window as the default output window for the vs editor by selecting ‘Run Current File in interactive Window’ from the drop-down menu next to the run code button at the top of the vs code editor panel. But this option produces editor output from the interactive window only once. If one runs the code file for a second time without once again selecting the ‘Run Current File in interactive Window’ from the drop-down menu, it will produce the output from the built-in terminal.

I have checked every line of the setting.JSON page but could not fix this issue. I have unchecked the ‘toggle terminal’ tab but still that is not making any difference.

Presently, I need to select ‘Run Current File in interactive Window’ manually every time I run the codes.

I have also tried to append the following JSON code to the setting file to run Python project files by default in the interactive window, but it seems that the setting.json file does not recognize this code:

`"python.runCurrentFileInInteractiveWindow": true

Searching high and low in this forum, I could not find any suggestions to set project file codes to run by default in the interactive window.

2

Answers


  1. Chosen as BEST ANSWER

    I may have found an answer to set the Jupyter Notebook as the default editor output window. No more default output from the built-in terminal unless specifically set to it. Right-click on the file name in the Explorer window instead of using the drop-down menu of the editor (top panel). Click on the 'Run Current File in the Interactive Window' the editor's default output will be set permanently to the interactive window. One need not add anything extra to the user or workbench.JSON file.

    p.s. The drop-down menu in the editor's top panel next to the run button will only set the output from the interactive terminal for only one run of the code file. When one tries to run using this method without once again selecting the 'Run Current File in Interactive Window', it will produce the output from the built-in terminal and not from the Interactive window.


  2. This is/was a bug. I raised a bug ticket at editor/title/run rememberDefault doesn’t remember that jupyter.runFileInteractive was last selected
    #210286
    . It seems that a partial fix was made in pull request remove unnecessary when condition so command can be menu defualt #15546, but there’s still some additional stuff to fix (the partial fix still requires the interactive window to already be open when selecting from the dropdown)- see editor/title/run doesn’t always switch the default action when selected from dropdown #210410. Sit tight and wait patiently. The full fix is on the way (April 2024 release of VS Code).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search