You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When we execute the command of Run Selection/Line in xxx, it only executes either the current line if nothing is selected or the selection. For example:
When I put my cursor at the first line, it would attempt to run dtypes = { only. But in the other IDEs such as RStudio, it's a little smart, it intelligently knows that the current line is part of a multiline statement and runs the whole statement.
Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.
Thank you to everyone who upvoted this issue! Since the community showed interest in this feature request we will leave this issue open as something to consider implementing at some point in the future.
We do encourage people to continue 👍 the first/opening comment as it helps us prioritize our work based on what the community seems to want the most.
This would be a great feature. FWIW, maybe looking at how other extensions do it might help. For example, the Julia extension uses Shift+Enter, and the R extension uses cmd+Enter to run multiline statements without any selection.
Reacted by Vincent Landau, Andrew Craig, Ali El-Said, Alvaro Carril and KatlehoJordan
I'd love this block-detection functionality so I'm going to have a try at creating an extension to provide it. My plan is to use the Python Extension Template and make it compatible with both the VS Code Jupyter and VS Code Python extensions.
In the meantime, if there's any move towards providing this functionality within the VS Code Jupyter or VS Code Python extensions themselves, please let me know as I'd very happily leave it to the pros!
Reacted by GitHunter0, Ali El-Said, Clemens Brunner and baslat
(This is mostly a copy of my comment in the vscode-jupyter thread here)
I used this functionality in Atom + Hydrogen every day, and now that Atom is dying in more places, I got so frustrated without this functionality in vscode that I made my own vscode extension for this. In this screencast, the only keyboard shortcut used is Shift+Enter, which runs a block and moves down to the start of the next block (Ctrl+Enter/Cmd+Enter are currently mapped to "run the current block but don't move the cursor)
Include the current line plus any additional lines that have a greater initial indent
Define a (user-editable) list of keywords that should be marked as "include this line even if it's at the same indent as the start line". So for example the default list includes elif and else, so that if your cursor is at the initial if line, the if plus elif plus else blocks all get evaluated at the same time.
The default setting for this is: else, elif, except, finally, }, ], ).
This heuristic generally works on most "clean" code; I assume it's possible to construct a case that would break the current implementation.
Using the block of text inferred by the above heuristic, call the jupyter.execSelectionInteractive command in the jupyter package
Caveats
I personally really love IPython and find the rich outputs (like dataframe rendering) useful, so the extension I wrote only supports the jupyter extension at this time and not the bare python extension.
I wrote this extension super fast, so it probably has bugs and I don't want to make any promises about my maintenance of it going forward.
Any plans by the VSCode-python team to pick this up? It's been >18 months, and if I am to believe the screencast by Kyle Barron (@kylebarron), then there's already a starting point to build upon...
We will post when we have anything to specifically share. Unfortunately this issue doesn't even make it to the first page of upvoted issues. But when we take on redesigning any REPL experience we will make sure this is taken into consideration.
Hi everyone! This is implemented in #21779 Feel free to check out the feature and also note there is setting to toggle Smart Send on/off with a warning that lets you know when feature usage is not possible due to invalid or deprecated Python code. Simply search for repl in extension setting.
Activity
karthiknadig commentedon Dec 2, 2021
Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.
palindali commentedon Dec 9, 2021
This feature request is based on this question on Stack Overflow, for reference.
brettcannon commentedon Feb 3, 2022
Thank you to everyone who upvoted this issue! Since the community showed interest in this feature request we will leave this issue open as something to consider implementing at some point in the future.
We do encourage people to continue 👍 the first/opening comment as it helps us prioritize our work based on what the community seems to want the most.
cbrnr commentedon Apr 5, 2022
This would be a great feature. FWIW, maybe looking at how other extensions do it might help. For example, the Julia extension uses Shift+Enter, and the R extension uses cmd+Enter to run multiline statements without any selection.
andycraig commentedon Sep 1, 2022
Equivalent feature request for Jupyter extension: microsoft/vscode-jupyter#1471
GitHunter0 commentedon Sep 3, 2022
RStudio related issue rstudio/rstudio#9014
andycraig commentedon Nov 19, 2022
I'd love this block-detection functionality so I'm going to have a try at creating an extension to provide it. My plan is to use the Python Extension Template and make it compatible with both the VS Code Jupyter and VS Code Python extensions.
In the meantime, if there's any move towards providing this functionality within the VS Code Jupyter or VS Code Python extensions themselves, please let me know as I'd very happily leave it to the pros!
brettcannon commentedon Nov 21, 2022
There's currently no movement on this from our side, so if you do create an extension please let us know!
kylebarron commentedon Dec 1, 2022
(This is mostly a copy of my comment in the vscode-jupyter thread here)
I used this functionality in Atom + Hydrogen every day, and now that Atom is dying in more places, I got so frustrated without this functionality in vscode that I made my own vscode extension for this. In this screencast, the only keyboard shortcut used is Shift+Enter, which runs a block and moves down to the start of the next block (Ctrl+Enter/Cmd+Enter are currently mapped to "run the current block but don't move the cursor)
Screen.Recording.2022-11-28.at.10.27.28.PM.mov
Implementation
The github repo for this is here: https://github.com/kylebarron/vscode-jupyter-python
This is based off of https://github.com/nteract/hydrogen and https://github.com/nikitakit/hydrogen-python, specifically the code here. The idea is pretty simple:
Include the current line plus any additional lines that have a greater initial indent
Define a (user-editable) list of keywords that should be marked as "include this line even if it's at the same indent as the start line". So for example the default list includes
elifandelse, so that if your cursor is at the initialifline, theifpluselifpluselseblocks all get evaluated at the same time.The default setting for this is:
else,elif,except,finally,},],).This heuristic generally works on most "clean" code; I assume it's possible to construct a case that would break the current implementation.
Using the block of text inferred by the above heuristic, call the
jupyter.execSelectionInteractivecommand in thejupyterpackageCaveats
I personally really love IPython and find the rich outputs (like dataframe rendering) useful, so the extension I wrote only supports the jupyter extension at this time and not the bare python extension.
I wrote this extension super fast, so it probably has bugs and I don't want to make any promises about my maintenance of it going forward.
KatlehoJordan commentedon Jun 22, 2023
Any plans by the VSCode-python team to pick this up? It's been >18 months, and if I am to believe the screencast by Kyle Barron (@kylebarron), then there's already a starting point to build upon...
This would be an excellent feature, 🤞
brettcannon commentedon Jun 22, 2023
We will post when we have anything to specifically share. Unfortunately this issue doesn't even make it to the first page of upvoted issues. But when we take on redesigning any REPL experience we will make sure this is taken into consideration.
REPL Smart Shift+Enter and Dynamic Smart Cursor (#21779)
anthonykim1 commentedon Dec 14, 2023
Hi everyone! This is implemented in #21779 Feel free to check out the feature and also note there is setting to toggle Smart Send on/off with a warning that lets you know when feature usage is not possible due to invalid or deprecated Python code. Simply search for repl in extension setting.