Keyboard shortcut to switch between python console and the editor in pycharm

In general, I'd like to know the keyboard shortcut for navigating to multiple sections like the project structure, editor, console. I'm using eclipse keymap configuration in pycharm. I used to switch between different views in eclipse using [ Ctrl + F7 ]. But that is not working in pycharm. I also used to use F12 to bring the focus back to the editor when the focus is on any other view. That is also not working in pycharm. Environment: Ubuntu 12.04 64bit.

1,145 3 3 gold badges 13 13 silver badges 29 29 bronze badges asked Nov 14, 2013 at 6:39 1,308 2 2 gold badges 12 12 silver badges 19 19 bronze badges Attention: Answer with most up-Votes is below accepted answer. Commented Feb 24, 2017 at 8:54

The accepted answer is not what I needed when I came across this post. You can bind a hotkey to Python's console and go back to editor via F12. (See my answer below). Bind "Python Console" (preference -> Keymap -> MainMenue.Tools "Python Console" to a keyboard shortcut. (e.g Alt-P). Then navigate to console via shortcut and back to editor via ESC.

Commented Jul 7, 2019 at 18:03 you should accept the actual answer to the question. Commented Jan 19, 2020 at 22:41

For anyones value, I mapped the Terminal window on my Mac to Cmd + 1 and the Python Console window to Cmd + 2 . You can't toggle straight between the windows - these commands activate and deactivate the windows - but I find them helpful.

Commented Apr 21, 2021 at 13:43

15 Answers 15

In Pycharm 4, you can specify shortcuts with

File / Settings / Appearance and Behaviour / Keymap

You can create any shortcut you like, and bind it to the command "Python Console" (search for Console), which has no default keymapping. Be aware that it is possible to have multiple consoles open at the same time (for example if you open one in the debugging window) so this may not always behave as you expect it to.

You can toggle back to the last editor window by hitting escape.

answered Dec 10, 2014 at 15:01 932 9 9 silver badges 12 12 bronze badges

"You can toggle back to the last editor window by hitting escape" - very useful thanks, this isn't obvious!

Commented Nov 12, 2015 at 16:50

This is the correct answer to the titled post "Keyboard shortcut to switch between python console and the editor in pycharm".

Commented Nov 19, 2015 at 3:01 This is the correct answer, Change View doesn't help you in navigating to Python Console. Commented Jan 22, 2016 at 12:39 You can also toggle back to editor by pressing the same Python Console key you assigned. Commented Feb 28, 2019 at 23:08

Somehow a newly assigned shortcut does get the "Python console" focused, but Pycharm does not allow me to type directly. Toggling the "show variables" window fixed the issue.

Commented Sep 16, 2019 at 15:36

If you mean the "Run" window (which has a console in it) you can open it/switch to it with Alt + 4 . See the screenshot for the two locations this is indicated.

As mentioned by vape, Esc should return you to your most recently used editor. Alternatively, pressing Alt + 4 again seems to return me to the first editor.

Locations of shortcuts (View Menu and dock bar)

11.6k 5 5 gold badges 33 33 silver badges 48 48 bronze badges answered Feb 4, 2014 at 23:39 Alan Hensley Alan Hensley 771 7 7 silver badges 9 9 bronze badges

This is useful in general, but unfortunately doesn't help when trying to navigate between editor window and the python console (title for this post by OP). The python console is listed in View -> Tool Windows but has no keyboard shortcut assigned. Am checking whether a custom keyboard shortcut can be assigned to make this work.

Commented Nov 19, 2015 at 2:52

Yes, can be done following the instructions provided in answer by @jafelds It is not required to bring up the View -> Tool Windows pane, you can just use whatever you map as the keyboard shortcut to Python Console, and use escape to return to Editor window

Commented Nov 19, 2015 at 3:01

@arcseldon This is the correct answer. The python console is a flavor of run and alt [/opt]-4 performs the correct navigation

Commented Mar 1, 2017 at 0:02

@javadba - to be honest, i cannot even remember leaving those comments 16 months ago :) Thanks for taking the time to reply - incidentally, which version of pycharm are you referring to? Been using webtstorm and intellij for the past year only - there's definitely been lots of updates and bug fixes in the interim.

Commented Mar 1, 2017 at 18:35

Using intellij not pycharm as well. I just wanted to affirm this answer as being correct: since there are many alternates flying around.

Commented Mar 1, 2017 at 18:39

Ctrl + TAB pops up the Switcher dialog. You can then either use repeated Ctrl + Tab to navigate to the window you want, or hit the corresponding number.

11.6k 5 5 gold badges 33 33 silver badges 48 48 bronze badges answered Feb 19, 2015 at 21:18 W.P. McNeill W.P. McNeill 16.9k 12 12 gold badges 82 82 silver badges 118 118 bronze badges

To switch from Editor to Console: CTRL + SHIFT + TAB
To switch from Console to Editor: SHIFT + ESC

This works for me on Ubuntu 16.04

2,762 1 1 gold badge 30 30 silver badges 36 36 bronze badges answered Oct 5, 2017 at 6:28 Sanath Sastry Sanath Sastry 157 1 1 silver badge 3 3 bronze badges

Based on the title of the question the answer seem to be simply: Alt + F12 .

This is true both for Eclipse bindings and the default.

It moves from the editor to the console/terminal and back when pressing it again. The only downside I see is that the terminal closes when moving back to the editor, I would like to keep it open and only move the focus.

11.6k 5 5 gold badges 33 33 silver badges 48 48 bronze badges answered Aug 6, 2015 at 9:18 19.9k 21 21 gold badges 97 97 silver badges 113 113 bronze badges

This should be the accepted answer. Closure of the console window is not necessarily a downside, it leaves you more space with the editor.

Commented Sep 1, 2016 at 12:43 alt-4 avoids the downside - it does exactly what is needed w/o side effects Commented Aug 20, 2017 at 17:12 this switches to the "Terminal" instead of the Python Console for me Commented Mar 8, 2019 at 21:08 Wrong. Console != Terminal. Commented Sep 15, 2020 at 14:52

Summarizing the answers I found:

Best:
- Bind "Python Console" (preference -> Keymap -> MainMenue.Tools "Python Console" to a keyboard shortcut. (e.g Alt-P). Then navigate to console via shortcut and back to editor via ESC.

Alternatives:
- Ctrl+shift+tab opens a menu to navigate to alternative Views, pressing "P" navigates to python console. ESC brings you back.
- Manually Clicking on python console and pressing ESC brings you back to editor. Alt+F12 navigates you to "previous" view.

answered Jul 7, 2019 at 18:02 Leo Ufimtsev Leo Ufimtsev 6,381 5 5 gold badges 42 42 silver badges 49 49 bronze badges

Updated answer for PyCharm 2020:

After trying them none of the previous answers seem to still apply so here is how to do it in PyCharm 2020.

To get into the python console where you can actually type commands (not just select the window) you have to rebind "Python or Debug Console" under Tools in the Keymap section of the settings (open with ctrl+alt+s)

Getting back to the editor is Escape by default but can be changed by rebinding "Focus Editor" under the Editor Actions folder.