简体   繁体   English

如何使用快捷方式从 Intellij 终端跳转到编辑器

[英]How to jump from Intellij terminal to editor with shortcut

I know that you can jump from almost all windows in Intellij IDEA to the editor window with Esc .我知道您可以使用Esc从 Intellij IDEA 中的几乎所有窗口跳转到编辑器窗口。 In Intellij's terminal window, this does not work.在 Intellij 的终端窗口中,这不起作用。 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.这会很好,因为我可以使用Alt + F12从我的编辑器跳转到终端,但如果不使用鼠标,我无法以其他方式执行此操作。

UPDATE - March 2016更新 - 2016 年 3 月

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 .默认情况下,它映射到Alt + F12 F12 To check other mappings, view it in the menu at View > Tool Windows > Terminal .要检查其他映射,请在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...".或者,转到“ 使用嵌入式本地终端” Web 帮助页面并更改右上角的键盘映射选项,然后滚动到最后(“另请参阅”部分的正上方),其中显示:“在嵌入式本地终端和编辑器按...”。 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] [2016 年 3 月结束更新]

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

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. Alt + F12第二次将带您返回编辑器,但会隐藏终端窗口。
  2. Alt + Home will take you to the navigation bar, then hitting Esc will take you to the editor. Alt + Home将带您到导航栏,然后按 Esc将带您到编辑器。 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 ).然后将其映射到快捷方式( 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 .虽然@vikingsteve 提到的Ctrl + Tab切换器中没有编辑器选项,但您可以执行Ctrl + TabCtrl + Shift + Tab Again, you could record that to a macro.同样,您可以将其记录到宏中。

If I think of any other ideas, I'll add them.如果我想到任何其他想法,我会添加它们。

Ubuntu: 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)

It might be an option to disable Preferences > Tools > Terminal > Override IDE shortcuts禁用Preferences > Tools > Terminal > Override IDE shortcuts可能是一个选项

Esc works after that Esc在那之后工作

Running IDEA 13 on OSX在 OSX 上运行 IDEA 13

Expanding on Mark Vedder's answer, here's my experience so far:扩展 Mark Vedder 的回答,这是我迄今为止的经验:

  1. F12 (Alt+F12) ( Terminal ) will toggle the terminal tool window visibility, so it will take you back to the editor once hidden. F12 (Alt+F12) ( Terminal ) 将切换终端工具窗口的可见性,因此一旦隐藏,它将带您返回编辑器。 Similar effect with (Shift+Esc)( Hide Active Tool Window ), which will hide the active tool window, putting focus back on the editor. (Shift+Esc)( Hide Active Tool Window ) 类似的效果,它将隐藏活动工具窗口,将焦点重新放在编辑器上。
    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)即使您确实设法通过其他工具窗口(例如项目工具窗口)中的快捷键触发宏,它也不起作用(即使Script execution finished将显示在 IDEA 窗口的底部)
    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).但即使它确实有效,它也会将编辑器切换到下一个文件,因此您仍然需要执行 才能返回原始文件(正如 Mark 指出的那样)。
    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!).虽然终端具有焦点,但只要您没有Preferences->Keymap重新分配它们,似乎仍然可以访问一些Tools快捷方式(非常重要的是您不要触摸这些 - 我尝试取消分配和重新分配 1Project ),它会不再从终端内触发!)。 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 (ie not normally visible), so whenever I need to break out of Terminal I simply type 2 x 2 .例如,我通常不使用Favorites Tool Window (即通常不可见),因此每当我需要退出终端时,我只需键入 2 x 2
    Maybe works for you?也许对你有用?

  5. The key, when used on any Tool Window , will shift focus back to the editor. 键在任何Tool Window ,会将焦点移回编辑器。 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 .因此,类似于 (4.),首先执行 2或任何其他工作快捷方式,将焦点从 Terminal 移到一个更正常的Tool Window ,然后执行
    Same as (4.)与 (4.) 相同

Another possibility:另一种可能:

Shift + Esc

(This one will close terminal panel) (这将关闭终端面板)

On OSX PhpStorm 8, 2 twice works.在 OSX PhpStorm 8 上, 2两次有效。 + numbers are not likely to be assigned as [default] shortcuts on OSX as they are special characters like ™ ( 2 ). + 数字不太可能被指定为 OSX 上的 [默认] 快捷方式,因为它们是像 ™ ( 2 ) 这样的特殊字符。

For me, only 2 , 6 , and 9 work with this idea, 2 being the least disruptive as @dev suggests.对我来说,只有 2 6 9符合这个想法, 2是@dev 建议的破坏性最小的。

There is an open ticket about the Terminal focus issue that might be worth following to see if this behaviour improves in the future.有一个关于终端焦点问题的公开票,可能值得关注,看看这种行为在未来是否有所改善。

从 2020 年开始,您可以使用相同的键 ( Alt + F12 ) 在终端和您所在的上一个窗口之间切换。

I believe the better answer is我相信更好的答案是

Alt + Home Alt + 主页

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.这是因为像Alt + F12这样的大多数答案都是关于关闭终端并希望焦点回到编辑器,但是使用Alt + Home焦点转到选择编辑器,有时焦点在文件上,但实际上是没有打开。 This way you can open it too.这样你也可以打开它。

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.并且您想使用 keybaord 快捷方式从终端跳转到编辑器。

Solution解决方案

  1. Assign 2 (or any other shortcut) to jump to terminal分配 2 (或任何其他快捷方式)以跳转到终端
  2. You have already 9 to jump to version control tab您已经 9跳转到版本控制选项卡
  3. Press 9 and Esc . 9Esc 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当您想转到终端时,只需按 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.您还可以在此屏幕截图中看到用于以拆分模式打开终端的设置。

在此处输入图片说明

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.您可以创建一个新的终端选项卡(在终端中按 Ctrl + Shift + T )并将选项卡标题拖动到编辑器区域,使其成为“普通”选项卡。

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.然后您可以使用alt + leftalt + right在编辑器选项卡和终端选项卡之间切换(在覆盖 IDE 热键模式下),或垂直拆分,分配“转到下一个拆分器”快捷方式并使用它进行切换。

  • This will active the editor again这将再次激活编辑器

  • Alt + 1 then Esc Alt + 1然后Esc

Injellij -> Preference -> Key Map -> search "terminal" -> . Injellij -> Preference -> Key Map -> 搜索“终端” -> .

find or change the shortcut there在那里找到或更改快捷方式

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM