How can I run just the currently selected lines in Spyder 4?

The hotkey for running a the line at which the cursor is, or the currently selected lines in Spyder 4 is F9. Ctrl+Enter will run the current cell. You can read more about cells in Spyder here. Basically, these are blocks of code that can be defined in the editor using a specific syntax within the code, and can be run independently by Spyder and other IDEs.

Incidentally, Ctrl+Enter is the keyboard shortcut for running the current line in R Studio, not Spyder, which may be where you got it confused.


In Spyder 4.0.1, the keyboard shortcut for 'run cell' is set to Ctrl+Return but for 'run selection' it is set to F9. You can use F9 to run a selection or if you prefer to use Ctrl+Return, you can go to Tools -> Preferences -> Keyboard shortcuts. Search for 'run selection', double click and set Ctrl+Return as the 'New shortcut'

Tags:

Python

Ide

Spyder