I am very new to Python and I am used to R studio so I choose Spyder. On the Spyder layout I saw a button 'run current line (ctrl +f10)'. But it doesn't work by pressing the button or c+10. Am I missing something? I can only select the script and 'ctrl+enter ' to run current line which is not convenient at all. I am using ubuntu with Anaconda distribution.
5 Answers
The key to run the current line by itself is F9
. The shortcut ctrl+F10
is used if you are in debugging mode.
You can see a list of shortcuts by selecting Preferences
in the Tool
menu, and then clicking on Keyboard shortcuts
.

- 4,492
- 26
- 23
-
In Spyder 3.3.6, on 2 different machines running _Windows 10_, _F9_ does not work for me but selecting the menu option _Run selection or current line_ does. Also, selecting the text and clicking _Ctrl+Return_ does work however! – boardtc Nov 07 '19 at 00:51
Coming from R studio I imagine you were hoping to have a command that runs the next command, rather than just that one row (which can break a command into several parts and cause errors).
The exact equivalent doesn't exist yet but if you get accustomed to adding #%% before and after chunks ("cells") you want to run together then you can use the following commands to run the whole chunk.
Run cell: Ctrl + Return
Run cell and advance : Shift+Return

- 499
- 8
- 15
-
3This answer was very useful as it gave context information from some coming from RStudio using Rnotebooks to Spyder for similar functionality. – ansek Jun 14 '19 at 00:49
F9
is the key that does the job for you.
To replicate the RStudio style, go to Preferences
in Tools
menu and go to Keyboard Shortcuts
.
Since Ctrl + Enter
is assigned to another function, change that first.
Then assign the F9
key value to Ctrl + Enter
. Now Spyder is the same as RStudio. Atleast in a way.

- 321
- 3
- 5
Some keyboards have a different layout than others in terms of what the keys are supposed to do. For me running happens if done via Fn + F9
.

- 417
- 6
- 15
Control Enter is a quick way of executing a line or block of code in both R Studio & Python.
In Spyder, make sure the line or block is highlighted before you hit 'ctrl-enter'

- 759
- 1
- 9
- 21