title: How to run code selection in Spyder without changing the active window to IPython console?
body: <p>This is mostly a question regarding work-flow in Spyder, and not a pure programming question. If anyone thinks it has no place here, then please let me know and I'll remove it.</p>
  
  <p>Here we go:</p>
  
  <p>I'm running Spyder on a Windows 64-bit operating system. The interaction between the Spyder IDE and IPython console depends on how you choose to run your code, and I would like to specify how this interaction works. </p>
  
  <p>Among several options to run parts of the code, the difference between the following two is what puzzles me:</p>
  
  <p><strong>Option 1 - Select parts of the code and hit F9</strong></p>
  
  <p>This runs the selected code. No surprise there.
  Hit F9 again, and the same selection is executed once more.
  <a href="https://i.stack.imgur.com/7UUHE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7UUHE.png" alt="enter image description here"></a></p>
  
  <p><strong>Option 2 - Run the same selection using Cells (#%%) and Ctrl+Enter</strong></p>
  
  <p>The code is run just like before. But hit Ctrl-Enter again, and nothing happens. Probably because the IPython console now is the active window.
  <a href="https://i.stack.imgur.com/TIxlR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TIxlR.png" alt="enter image description here"></a></p>
  
  <p>I would like to find some way of changing this so I can use Ctrl+Enter and run the cell contents multiple times without having to make the Spyder IDE the active window by manually clicking on it. I don't know if this is possible at all. Googling and messing around in the settings under <strong>Run / configure</strong> and <strong>Tools / Preferences</strong> has so far been useless.</p>
  
  <p>Thank you for any suggestions!</p>
  
  <p>P.S</p>
  
  <p>In case you're wondering why this is such a big deal to me, I'm rendering multiple charts and exporting them to Power Point with minor changes each time the code is run. This way, new parts of the charts (lines, textboxes, etc) are revealed when I'm working my way through a finished Power Point presentation. And for my basic data science needs, this has turned out to be a pretty much optimal work-flow. Except, of course, that I have to manually select the Spyder IDE each time I run different selections of the code.</p>