How to jump from Intellij terminal to editor with

2019-01-21 08:40发布

问题:

I know that you can jump from almost all windows in Intellij IDEA to the editor window with Esc. In Intellij's terminal window, this does not work. Does anyone know how to do this with a keyboard shortcut? This would be nice since I can jump from my editor to the terminal with Alt+F12 but I cannot do it the other way without using my mouse.

回答1:

UPDATE - March 2016

Since this question is getting some attention, I wanted to remind everyone that you can toggle between the editor and the terminal window easily enough with a built in action. By default it is mapped to Alt+F12 and F12. To check other mappings, view it in the menu at View > Tool Windows > Terminal. Alternatively go to the Working with Embedded Local Terminal web help page and change the Keymap option in the upper right corner and scroll to the very end (just above the "See also" section) where it says: "Toggle between the embedded local terminal and editor by pressing...". You can remap this action in Settings > Keymap > Other > Terminal

The main "issue" this question discusses is if there is a way to return from the terminal window to the editor without closing the terminal window.

[End March 2016 update]

===================================================

Some options I can think of at the moment.

  1. Alt+F12 a second time will take you back to the editor, but will hide the terminal window.
  2. Alt+Home will take you to the navigation bar, then hitting Esc will take you to the editor. If you do this often enough, to eliminate the need for the double sequence you could record a Macro (Edit > Macros) with the sequence. Then map it to a shortcut (Settings > [IDE Settings] > Keymap > Macros). The nice thing about this option is that it will work from any tool window. So you can get use to it as a consistent "Return to the Editor" shortcut.
  3. While there is no editor option in the Ctrl+Tab switcher that @vikingsteve mentions, you could do Ctrl+Tab, Ctrl+Shift+Tab. Again, you could record that to a macro.

If I think of any other ideas, I'll add them.



回答2:

Ubuntu:

alt + 2(twice) - jump from the terminal to the editor
alt + F12 - open the terminal 

Mac:

cmd + 2(twice) - jump from the terminal to the editor
options + F12 (this shortcut toggles the terminal window on and off)


回答3:

It might be an option to disable Preferences > Tools > Terminal > Override IDE shortcuts

Esc works after that



回答4:

Running IDEA 13 on OSX

Expanding on Mark Vedder's answer, here's my experience so far:

  1. F12(Alt+F12) (Terminal) will toggle the terminal tool window visibility, so it will take you back to the editor once hidden. Similar effect with (Shift+Esc)(Hide Active Tool Window), which will hide the active tool window, putting focus back on the editor.
    No good if you want Terminal visible at all times

  2. While it's a great idea to record a macro that will take you back to the editor through scripted interaction, it fails to work in practice. For one thing, Terminal will intercept most key strokes, so you won't be able to trigger the macro. Even when you do manage to trigger the macro through its shortcut key from some other tool window (the Project tool window for example), it won't work (even though Script execution finished will display along the bottom of the IDEA window)
    Doesn't work

  3. won't work either as the Terminal window seems to intercept most key combinations. But even if it did work, it would switch the editor to the next file, so you'd still need to do a to return to the original one (as Mark pointed out).
    Doesn't work but don't really mind as it spares another annoyance

  4. While Terminal has focus, it appears some Tools shortcuts are still accessible as long as you haven't reassigned them in Preferences->Keymap (very important you don't touch these - I tried unassigning and reassigning 1(Project) and it would no longer trigger from within Terminal!). Invoking any of these shortcuts twice will toggle that Tool window, eventually taking you back to the editor. For example, I don't normally use the Favorites Tool Window (i.e. not normally visible), so whenever I need to break out of Terminal I simply type 2 x 2.
    Maybe works for you?

  5. The key, when used on any Tool Window, will shift focus back to the editor. So, similar to (4.), first do 2 or any other working shortcut to move focus out of Terminal to a more well-behaved Tool Window, then .
    Same as (4.)



回答5:

On OSX PhpStorm 8, 2 twice works. + numbers are not likely to be assigned as [default] shortcuts on OSX as they are special characters like ™ ( 2).

For me, only 2, 6, and 9 work with this idea, 2 being the least disruptive as @dev suggests.

There is an open ticket about the Terminal focus issue that might be worth following to see if this behaviour improves in the future.



回答6:

Another possibility:

Shift + Esc

(This one will close terminal panel)



回答7:

Injellij -> Preference -> Key Map -> search "terminal" -> .

find or change the shortcut there



回答8:

Assumption

This solution assumes that you want to leave the terminal and version control tab (or any tab) always open and don't want to close any of them. And you want to jump from terminal to editor using keybaord shortcut.

Solution

  1. Assign 2 (or any other shortcut) to jump to terminal
  2. You have already 9 to jump to version control tab
  3. Press 9 and Esc. This will take you to editor and both the version control tab and terminal will remain open
  4. When you want to goto terminal just press 2

Webstorm screenshot

You can see my webstorm, I alway open two tabs at bottom. And you can also see the settings of terminal in this screenshot which are used to open it in split mode.



回答9:

I believe the better answer is

Alt + Home

This is because most of the answers like Alt + F12 are about closing the terminal and hoping the focus goes back to the editor, but with Alt+Home the focus goes to selecting the editor and sometimes the focus is on the file but it actually is not opened. This way you can open it too.



回答10:

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.

Then you can use alt+left and alt+right for switching between editor tab and terminal tab (when in override IDE hotkeys mode), or split vertically, assign "go to next splitter" shortcut and use it for switching.



回答11:

  • This will active the editor again

  • Alt + 1 then Esc