spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.3k stars 1.61k forks source link

Automatically advance to the next line after pressing F9 #3115

Closed ckaldemeyer closed 8 years ago

ckaldemeyer commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

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 commented 8 years ago

@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 commented 8 years ago

Agree on F9 move to the next line :+1:

ckaldemeyer commented 8 years ago

@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 commented 8 years ago

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 commented 8 years ago

Thanks a lot!

pankajs99 commented 8 years ago

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

jitseniesen commented 8 years ago

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 commented 8 years ago

:+1:

ccordoba12 commented 8 years ago

@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 commented 6 years ago

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 commented 2 months ago

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 commented 2 months ago

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