141

Edit: my system had global key map which had overridden PyCharm. Here's the original question:

I've tried these answers, but nothing happened: Keyboard shortcut for Jump to Previous View Location (Navigate back/forward) in IntelliJ IDEA

For example:

  1. I'm navigating to a function body,
  2. put the cursor on a function call,
  3. click F12 ("go to definition")
  4. from the new location (the function's body), how do I return to the function call?

I've tried these, but they didn't do anything:

  • Ctrl+Shift+Left
  • Ctrl+Shift+F2 <-- this is my default mapping
  • Alt+Shift+Left
  • Ctrl+Shift+backspace
  • don't try that on linux: Ctrl+Alt+backspace

Or maybe F12 ("go to def") isn't "strong enough" to trigger a location-change event?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Berry Tsakala
  • 15,313
  • 12
  • 57
  • 80

13 Answers13

136

Under ArchLinux with PyCharm CE 3.1 works the combination Ctrl + Alt + Left.

This is the way I find out the combination:

  1. (Right click) Go To -> Implementation(s)

  2. Double Shift -> Back

    enter image description here

  3. There is an option Back in the section Actions

  4. Ctrl + Shift + A

    enter image description here

  5. And then the cursor comes back

bad_coder
  • 11,289
  • 20
  • 44
  • 72
awesoon
  • 32,469
  • 11
  • 74
  • 99
  • 2
    thank you for the useful "actions" tip (upvoted, fwiw), but as i mention - ctrl-alt-left didn't work for me, hence, irrelevant. see my answer – Berry Tsakala Aug 03 '14 at 11:38
  • 7
    just a warning - on windows 7, ctrl-alt-left arrow rotates the screen! – Melanie Feb 19 '15 at 03:08
  • 1
    @Melanie, It is, probably, because of your graphics settings. As far as I remember, there is some shortcuts for rotating / mirroring / duplicating / etc. shortcuts in Intel Graphics module. – awesoon Feb 19 '15 at 03:45
  • 1
    In version 2017.2.3 (probably before as well) this has been changed to alt-shift-left – Dunes Oct 23 '17 at 13:33
  • Both ctrl+alt+left and shift+alt+left works for me (pycharm 2017 2.3) – awesoon Oct 23 '17 at 13:35
  • Unsurprisingly, you can then also "go forward again" using ctrl-alt-right. – J.G. Apr 19 '18 at 10:17
  • On pycharm 2020 (linux) I have `Shift-Alt-Left` (not `Ctrl-Alt-Left` anymore) as default for the `Back` action. – Michele Piccolini Jun 17 '20 at 13:44
  • `Back` does switching tabs for me. Just like `Ctrl+PgUp`, `Ctrl+PgDn` do. If my files are already opened it doesn't switch just `back` to the previous code (like if I'm dropping into function Declaration). Sad thing, but I can't find a solution. – egvo Jun 10 '21 at 07:47
72

All in all, it has nothing with PyCharm;

In my case, there was a global key combo of another program, that masked Ctrl-Alt-Left

I solve it by remapping "file > settings > keymap > main menu > navigate > back".

I chose Alt+Left, which intuitively feels likes web browsers "back" behavior.

Benyamin Jafari
  • 27,880
  • 26
  • 135
  • 150
Berry Tsakala
  • 15,313
  • 12
  • 57
  • 80
55

In mac OS X (atleast in El Capitan) it is by default cmd + [ to go back to the previous location.

update: if that doesn't work also try option+cmd+left arrow

mithunpaul
  • 3,268
  • 22
  • 19
41

Update for year 2016 to at least 2020.1.1:

In PyCharm 2016+ on windows the correct default is Ctrl+Shift+Backspace

https://www.jetbrains.com/help/pycharm/2016.2/navigating-to-next-previous-change.html

Be warned that Ctrl+Alt+Left will rotate your entire screen on Windows 10. If you're reading this with your head cocked sideways, Ctrl+Alt+Up will get you back vertical!

David Parks
  • 30,789
  • 47
  • 185
  • 328
16

Alt + Shift + left

The above works with PyCharm 2016.3.2 if you select the keymap "default for GNOME".

Georgy
  • 12,464
  • 7
  • 65
  • 73
Niklas Rosencrantz
  • 25,640
  • 75
  • 229
  • 424
14

PyCharm 2019.1+

This version of PyCharm has a new functionality called Recent Locations. This is useful when you find yourself needing to move back and forth between different locations in the code.

You can use the Recent Locations popup (Ctrl+Shift+E, or ++E on macOS) to get you to your destination quicker.

enter image description here

lmiguelvargasf
  • 63,191
  • 45
  • 217
  • 228
6

On macOS (Sierra; 10.12.6) and PyCharm 2017.3.1 (Professional Edition; built on December 13, 2017), if you're using the Go To -> Declaration (⌘+B), you can jump back and forth using ⌘+⌥+◀ or ▶.

mairan
  • 303
  • 5
  • 14
5

In Ubuntu Ctrl+Alt+Left is overridden in for switching to left workspace. I don't use workspaces at all so I cancelled that shortcut in System Settings -> Keyboard -> Shortcuts -> Navigation -> Switch to workspace left.

Georgy
  • 12,464
  • 7
  • 65
  • 73
mapcuk
  • 800
  • 1
  • 7
  • 21
5

I have the following environment:

  1. Ubuntu 16.04 (GNOME)
  2. VNC viewer.
  3. PyCharm 2019.1 (Community edition)

In my case, when examing the "Back" navigation settings it indeed indicated that it is set to Ctrl + Alt + Left , YET it did not work. What DOES work is Alt + Shift + Left.

Guy Avraham
  • 3,482
  • 3
  • 38
  • 50
5

Since I don't have commenting rights, answering here. Note that if you have side buttons on your mouse, you can also use Mouse button 4 and Mouse button 5 to move to previous and next cursor position respectively. Just in case you don't want to remap your keys in Pycharm since Ctrl+Alt+Left doesn't seem to work on for me on Windows 10 with Pycharm 2020.2.3

Have a look at the key mapping based on @Berry Tsakala's answer

Hawklaz
  • 306
  • 4
  • 20
3

I found the solutions don't go with mac. But I found that Shift + Command + Return takes you to location that you were working with.

To further explain, if you have pressed Command + Mouse click to navigate to a function, pressing the above combination takes to directly to the call.

Georgy
  • 12,464
  • 7
  • 65
  • 73
JAugust
  • 557
  • 1
  • 5
  • 14
3

Search for Back in the Settings ‒> Keymap, click on it and change it for what you want ‒ should help on all systems.

I use Ubuntu so the default was Ctrl + Alt + Left, but this combination is already in use by the system.

Ronald Luc
  • 1,088
  • 7
  • 17
0

This page from the Pycharm documentation is quite useful for this... https://www.jetbrains.com/help/pycharm/navigating-through-the-source-code.html

Here's the relevant table... enter image description here

Ben
  • 4,798
  • 3
  • 21
  • 35