3 ms·
Can I get the following behavior from Spyder (last time I tried I couldn't find a way) - for some keyboard shortcut like Cmd/Ctrl + Enter: - the shortcut sends
by superbcarrot 6y ago
Can I get the following behavior from Spyder (last time I tried I couldn't find a way) - for some keyboard shortcut like Cmd/Ctrl + Enter:
- the shortcut sends the selected code to the terminal (this is possible)
- if I hit the shortcut when nothing is selected, the line where the cursor currently is gets sent to the terminal and the cursor moves to the next line of code
- if the cursor is at the beginning of a block of code like an if-statement or a loop, the whole statement is sent to the terminal and the cursor moves to after the statement
RStudio has this behaviour by default, I find it very convenient and I haven't been able to replicate it in other environments.
- dplavery92 6y agoThat sort of workflow sounds a lot like what you would get from a notebook like Jupyter, albeit you would have explicit block of code ("cells") to be executed together. It looks like Spyder now features Jupyter Notebook integration as well: https://github.com/spyder-ide/spyder-notebook https://github.com/spyder-ide/spyder-notebook
- navbaker 6y agoYou can define code cells in Spyder and execute them with a shortcut. I’m on an older version, but for me it’s “# In[]” to start a code block, then shift-enter to execute. -Edit: to clarify, that string starts a code block, which continues until end of file or you designate another block. Executing the current line or the selected lines is just F9.
- omarhaneef 6y agoAs a sibling points out, I use F9. I prefer the control enter because I am used to enter to execute, but it is fine.
- kleiba 6y agoRStudio has this behaviour by default, I find it very convenient and I haven't been able to replicate it in other environments. Certainly you can replicate that in Emacs?!