Reputation: 1873
For the sake of illustration:
df = pd.read_csv(
'df.csv'
, sep=','
)
where the single command takes on multiple clauses. For readability it has been split into multiple lines. I would like to be able to run the above by placing the cursor on the 1st line and use Ctrl + Enter, where I would expect Spyder to auto advance to the next line (code not run yet), where I use Ctrl + Enter again, advances to next line. So on till I get to the 4th line (and the last Ctrl + Enter) where the entire block (cell) of code is run. As is the case with R.
However, currently I am only able to run the above by highlighting all 4 lines and using Ctrl + Enter.
I have found this thread: How to automatically advance to the next line after F9 in Spyder IDE However, F9 does not auto advance by 1 line at a time. Rather, it runs everything on and below the cursor (as I believe it runs the cell and no cell is defined).
I also found: https://github.com/spyder-ide/spyder/issues/3115 where jitseniesen came up with a function to achieve the above. However, is there a native Spyder way?
Finally, I have also resorted to defining cells using #%%
as below:
https://docs.spyder-ide.org/editor.html
This is, thus far, the only viable solution. Though it is not ideal because after placing cursor on #%% and using F9 the cursor stays on the same line (not auto advancing)
p.s. I have Spyder 4.0.1 I genuinely look forward to any answers and hope I have not missed anything. Thank you
Upvotes: 2
Views: 1091
Reputation: 34156
(Spyder maintainer here) You said:
I would like to be able to run the above by placing the cursor on the 1st line and use Ctrl + Enter, where I would expect Spyder to auto advance to the next line (code not run yet), where I use Ctrl + Enter again, advances to next line
This is not possible right now, sorry. You either have to select the whole region with the mouse or use cells as you mentioned above.
Though it is not ideal because after placing cursor on #%% and using F9 the cursor stays on the same line (not auto advancing)
To execute a cell you need to use Shift+Enter
(run current cell and advance) or Ctrl+Enter
(run and stay in the same cell), not F9
.
Upvotes: 2