Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically advance to the next line after pressing F9 #3115

Closed
ckaldemeyer opened this issue Apr 13, 2016 · 14 comments
Closed

Automatically advance to the next line after pressing F9 #3115

ckaldemeyer opened this issue Apr 13, 2016 · 14 comments

Comments

@ckaldemeyer
Copy link

There's already a question on stackoverflow that perfectly describes my question:

Coming from RStudio, I'm familiar with the behavior of the cursor automatically moving to the next line after running the current line. I think this makes sense for data analysis. Does Spyder have something similar?

I'm familiar with the concept of cell and auto-advancing cell in Spyder. However, I want to maintain a pure Python script (that can be run with python file.py) for portability, and don't want to use something that only makes sense on Spyder.

I know some people in my working group and other institutions that would already like to have such a shortcut for procedural data analysis scripts, plotting, ...

Is there a way to realize that behaviour (without using code cells)?

@ccordoba12
Copy link
Member

I can easily make F9 to advance to the next line, but I think it's much nicer to use cells.

Please remember that cells are comments (so there's nothing special about them) of the form

#%% One cell

#%% Another cell

They are just interpreted by Spyder to break a file in regions that can be evaluated independently of the rest :-) But there's no problem in running python myscript.py with that kind of comments :-)

However, @ckaldemeyer please let me know if this is a really important feature for you and/or your team or colleagues, and I'll add it to the next Spyder release :-)

@ckaldemeyer
Copy link
Author

Hi Carlos,

thanks for your answer!

I know the concept of cells and already make use of it in certain scripts to group semantical connected blocks of code.

But I think a shortcut "run current line and advance" would be a nice addition to go through procedural scripts line by line without having to define cells. I think this would be a valuable feature for many users that use Python for data analysis and statistics coming from languages like R. And I know various people from my institution who would appreciate it.

My opinion on the implementation: A definable keyboard shortcut under "Preferences > Keyboard shortcuts" would also be o.k.

Thanks a lot!

Cheers
Cord

@ccordoba12
Copy link
Member

@ckaldemeyer, I think making F9 to move to the next line is the thing to do (instead of introducing a new shortcut that does something slightly different :-).

@goanpeca, what do you think?

@goanpeca
Copy link
Member

Agree on F9 move to the next line 👍

@ckaldemeyer
Copy link
Author

@ccordoba12 and @goanpeca : That's great, thanks! Will it be in the next version? And what are your plans on the releases? Do your have a fix cycle or release as time allows you?

Best!

@ccordoba12
Copy link
Member

We have bugfix releases for the 2.3 branch, but they are limited to really critical bugs (like freezes and crashes).

That's why I tagged this issue for Spyder 3.0. We hope to release it next month :-)

@ckaldemeyer
Copy link
Author

Thanks a lot!

@ccordoba12 ccordoba12 modified the milestones: v3.0beta4, v3.0rc1 Apr 25, 2016
@pankajs99
Copy link

Very much needed..looking forward to it..!

@jitseniesen
Copy link
Member

I made a pull request to address this.

If the user selects some text in the editor and then presses F9, the existing behaviour is to run the selection. I chose not to move the cursor to the next line in that case, because it's not clear (to me) that that is the right thing to do.

@ckaldemeyer
Copy link
Author

👍

@ccordoba12 ccordoba12 modified the milestones: v3.0beta3, v3.0rc1 May 13, 2016
@ccordoba12
Copy link
Member

@jitseniesen, I think what you did is the right thing to do, i.e. don't move the cursor to the next line if there's text selected :-)

@httassadar
Copy link

Can we add an option to stop this auto advancing behavior please?

Most times when I run the code line-by-line, I would like to check the result after running each line. So after running

A = f(x)

I can immediately go shift-right to highlight A and F9 to print A.

@rfeir
Copy link

rfeir commented Aug 1, 2024

Hello,

In RStudio, the CTRL + RETURN command skips past comments to whatever the next command line would be. This is great as you can quickly work through a file with comments. Most importantly, though, if there is a command that spans multiple lines, such as a dictionary or loop, it will run the whole thing and move on. Could this be incorporated as a new command? I've found this hotkey allows me to keep my fingers on the keyboard. Navigating and editing feels very natural.

@ccordoba12
Copy link
Member

Hey @rfeir, we'll try to address your request in Spyder 6.1, to be released in six months or so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants