Shortcut to switch between editor and terminal?

I like to leave my terminal on while coding, and find myself clicking between editor and terminal window a lot.

Is there a shortcut to switch focus between the 2 (editor and a tool window)?

20
21 comments

Hi there,

Well ... Alt+F12 is a shortcut to open/hide Terminal panel (check "View | Tool Widows | Terminal" to see actual shortcut that you may have on your computer; it can be changed in "Settings/Preferences | Keymap")

Unfortunately that shortcut will hide Terminal when invoked fro the second time (inside the Terminal, e.g. to move from Terminal to the Editor -- standard behaviour for other tool windows as well).

Possible solution: disable "Override IDE Shortcuts" option in "Settings/Preferences | Tools | Terminal" (https://youtrack.jetbrains.com/issue/IDEA-116221) -- this will allow to use standard Esc to move focus back to the Editor (works from any tool window).

Other than that: https://youtrack.jetbrains.com/issue/IDEA-116865 (to be able to assign another shortcut to focus the Editor instead of rather hardcoded Esc)

15

Cool. I think that would work for me.
So I guess I should make a feature request if I want a shortcut that toggles between editor and terminal?

I think it's a frequently used feature. 

Just that I'd been relying on an external terminal before, but only recently decided to reduce dependency on other apps.

5

>So I guess I should make a feature request if I want a shortcut that toggles between editor and terminal?

It's up to you.

But most likely you will get similar answer to what I have suggested. I have big doubts that devs will introduce special shortcut just for navigating to and from specific window.

2

It is not really from and to a specific window. Is to the editor (like the most important window!). You can't consider ESC as a keybind as it is broken for the terminal.

8

@Andybergon

>it is broken for the terminal

It's not "broken" -- it's more of a "conflict of the interests" -- some people (possibly majority) want Esc to always switch to the Editor .. but some want to still be able to actually press it in the Terminal (as some programs do have a use for it).

As mentioned in the first comment -- you can tell IDE to pass all keys to IDE first ("Override IDE Shortcuts" option) so Esc will work as desired (will take focus there) but then it will stop working in actual Terminal...

Let's hope that devs will implement more dedicated action that would allow to bind other shortcut than Esc for those who want to have Esc to keep working in Terminal and have some another shortcut for switching into the Editor (tickets to watch after/vote/comment are in my first comment).

8

Wish they would address this in https://intellij-support.jetbrains.com/hc/en-us/community/posts/206375799-Keyboard-Shortcut-Focus-on-Editor?page=1#community_comment_115000519244.

For now I have to change my focus to one of the sidebars and then hit escape. Not the most ideal flow. I was considering switching to vsCode the other day partially related to this. 

2
Avatar
Permanently deleted user

I use Ctrl + Tab (this is on Linux)


From editor:

Ctrl + Tab, (still holiding Ctrl) T

From terminal:

Ctrl + Tab, (optional: keep holding Ctrl and navigate between editor panes with arrow keys)

24
Avatar
Permanently deleted user

@Benjamin Aaron March

This works great to focus the terminal, thanks for the tip!

Here's a somewhat convoluted improvement to switch back to the same editor tab (also tested on Linux):

From editor: Ctrl + Tab, then: hold Ctrl, add Shift, and press Tab

2
Avatar
Permanently deleted user

@Mikael Francoeur

You can go back to the editor tab with "Esc" key :)

4
Avatar
Permanently deleted user

It's silly to me that the one window that does not have a 'focus' action that is configurable is the Editor. E.g...

- Editing a file, navigate to the file drawer to [open a file, create directory, create file etc...] then back to the editor.
- Editing a file, navigate to the terminal to start a serve or debug process, and focus back to the editor to edit the file

Just a couple daily examples of using the Editor after doing something else in the IDE. The ESC key thing is nice, but not ideal because it's not configurable.

Suggestion: I'd like to set it to Command or Ctrl + 2 so I can access the editor like the other windows, so just needs to be configurable really.

2

I've got to add one more trick which I've recently discovered: you can create a new Terminal Tab (Ctrl-Shift-T while in terminal) and drag the tab header to the editor area, just making it a "normal" tab (you can also rename the tab header, which is handy for multiple terminal tabs). 

Thus you can use alt-left alt-right for switching between editor (when in override IDE hotkeys mode), i usually assign "go to next splitter" shortcut and split working area vertically or horizontally in as many terminal windows as I need.  

 

 

0
Avatar
Permanently deleted user

Jumpt to terminal: Alt + F12

Jump back to editor: ESC*

*You'll need to disable the: "Preferences > Tools > Terminal > Override IDE shortcuts" option first 

 

Alternative to go back to the editor: Ctrl + Tab and then select the editor you want. 

7

This omission is uncharacteristic for IntelliJ.  Webstorm is the premium, ie. best editor available.  I literally recommend it to my entire class of programming students ... and yet it can't handle one of the most basic tasks that at least half of all Node programmers are going to want to do?  Write some code, run it at the command line, repeat is an extremely common workflow, and it should be trivial for WebStorm-users to accomplish it.

Honestly, in my opinion the keyboard navigation in WebStorm in general could use a revamp.  Programmers are at great risk of RSI, and avoiding the mouse is a key way to help prevent that.  It should be trivial for a Webstorm user to move from file1 <=> file2 <=> the terminal <=> test results, etc.  There should be a single, predictable key combination that always takes me to the pane I want to go to (something mouse users take for granted).

Right now it's just a mess of stuff like CTRL + TAB (which is not a solution because it's unpredictable: I want to press ___ and go to where I expect, just like I can easily do with a mouse).

1
Avatar
Permanently deleted user

+1 - would be really nice to be able to do this.

0
Avatar
Permanently deleted user

Just a quick note to mention that the solution provided by Oscar Reyes works!

You need to disable the following checkbox from the IDE's settings:

"Preferences > Tools > Terminal > Override IDE shortcuts"

This allows you to hit ESC key and go back to the editor, same as it happens when you're navigating thru the project files.

Example Workflow:

  • ALT + F12 to open terminal
  • ESC to go back to editing file
  • ALT + F12 to focus on terminal
  • CMD + T to open new tab in terminal
  • ESC to get back to file
  • ALT + F2 twice to minimise terminal window, and go back automatically to editing file
  • ALT + F2 at some point later to re-open terminal (with existing tabs from before)
  • CMD + SHIFT + ] / CMD + SHIFT + [ to switch between the Terminal tabs

In case the shortcut key doesn't do what you expect it is probably because it's assigned to something already in Keymap. Go to Preferences -> Keymap and you can search for that shortcut key (tip: there's a way to search by actually typing in the shortcut key!). Once you find it, remove the keybinding.

1

Another solution is to change "view mode" of terminal to "Window" and just hit Alt + Tab to switch between editor and terminal.

No conflict, already used shortcut and visual preview.

0

Alt-F12 and Esc work out of the box for my PHPStorm to switch to the Terminal and back to the tab I was editing.

Alt-F12 is a little cumbersome, but I switched it to Alt-Shift-E to be easy (I'm on Windows, but a similar Mac shortcut would be Cmd+Shift+E).

Yay for JetBrains! 

1

I'm on Mac Catalina and I find the Option+F12 shortcut (to open/switch to/close the Terminal panel) and Esc while in Terminal to go back to file tab (either way goes back) to be adequate.

I'm not aware of the Esc issue in Terminal that is mentioned...

It would be nice to know shortcuts like "Go [back?] to File tab panel" or just "Go [back?] to Terminal panel" specifically... maybe this appears redundant, but being able to see and set those in Keymap might eliminate a lot of confusion or hassle figuring out how to switch (if this forum thread is not easily found).

0

For Mac : 

Terminal : Option + F12
Editor : Esc

1

I would like to be able to configure a single shortcut to toggle between the editor and the terminal instead of 2. I tried messing with the settings, but obvious that didn't work.

0

There is almost no single shortcut to toggle between the editor and the terminal. By “almost” I meant that a “Tool Windows > Terminal” shortcut actually toggles the terminal but it also hides it when you toggle to the editor. 

1

Please sign in to leave a comment.