如何导航到 Eclipse 中的最后一个光标位置?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12313308/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 21:18:09  来源:igfitidea点击:

How to navigate to the last cursor position in Eclipse?

eclipsekeyboard-shortcuts

提问by Jainendra

Recently, I switched from Visual Studioto Eclipse. Now I am missing the shortcut for navigating to the last cursor position in Eclipse. In Visual Studio, the same can be done with the help of the Ctrl+ -shortcut.

最近,我从Visual Studio切换到Eclipse。现在我缺少导航到 Eclipse 中最后一个光标位置的快捷方式。在 Visual Studio 中,同样可以在Ctrl+-快捷方式的帮助下完成。

How do I do this in Eclipse?

我如何在 Eclipse 中执行此操作?

回答by Denys Séguret

Go to Preferences / General / Keys. You'll be able to see or edit the bindings for:

Preferences / General / Keys。您将能够查看或编辑以下各项的绑定:

  • Backward History: default is Alt
  • Forward History: default is Alt
  • Backward History: 默认是 Alt
  • Forward History: 默认是 Alt

You may also use those shortcuts (and see the key bindings) in the toolbar:

您还可以在工具栏中使用这些快捷方式(并查看键绑定):

Enter image description here

在此处输入图片说明

回答by Baldrick

There is Altleft arrowand Altright arrowto navigate to previous/next cursor positions, and CtrlQto go to the last edited position.

Altleft arrowAltright arrow导航到上一个/下一个光标位置,并CtrlQ转到上次编辑的位置。

回答by krm

I'm adding an answer, because I'm not allowed to comment yet. Though the dystroy's answer contains information about useful shortcuts, I'm not satisfied with it, because the mentioned Alt+left shortcut doesn't always navigate to the last cursor position (e.g. in the same file). I'm not sure how it works in Visual Studio, but in IntelliJ a similar shortcut always moved the cursor to the last cursor position, even in the same file. I would like to have such functionality also in Eclipse. For example: I move the cursor using the keyboard's down arrow key successively on lines 10, 20, 30. Now I am on line 30 and when I press Alt+left I would like the cursor to go to the line 20. After pressing Alt+left again I would like the cursor to go to line 10.

我正在添加一个答案,因为我还不允许发表评论。尽管dystroy 的回答包含有关有用快捷方式的信息,但我对此并不满意,因为提到的Alt+left 快捷方式并不总是导航到最后一个光标位置(例如在同一文件中)。我不确定它在 Visual Studio 中是如何工作的,但在 IntelliJ 中,一个类似的快捷方式总是将光标移动到最后一个光标位置,即使在同一个文件中也是如此。我想在 Eclipse 中也有这样的功能。例如:我在第 10、20、30 行上连续使用键盘的向下箭头键移动光标。现在我在第 30 行,当我按 Alt+left 时,我希望光标转到第 20 行。按 Alt 后+left 再次我希望光标转到第 10 行。

In Eclipse, when the cursor was in file A and I opened file B and moved the cursor down a few lines in file B, then Alt+left will move the cursor to the file A, instead of moving it to a previous cursor position in file B.

在 Eclipse 中,当光标在文件 A 中并且我打开文件 B 并将光标在文件 B 中向下移动几行时,然后 Alt+left 会将光标移动到文件 A,而不是将其移动到文件 A 中的前一个光标位置文件 B。

I created a separate question for this problem: How to navigate to the last cursor position in Eclipse if it is in the same file and was not edited?

我为此问题创建了一个单独的问题: 如果 Eclipse 位于同一文件中且未被编辑,如何导航到 Eclipse 中的最后一个光标位置?

回答by JerryP

In Mac (OSX), the commands are ?[ and ?]. They are very convenient navigation commands when coding.

在 Mac (OSX) 中,命令是 ?[ 和 ?]。它们是编码时非常方便的导航命令。