windows 如何在 Eclipse 中打开文件并跳转到特定行?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2295414/
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-15 13:58:45  来源:igfitidea点击:

How to open a file in Eclipse AND jump to a specific line?

windowseclipse

提问by powtac

I can open a file in exclipse, but is there any syntax to jump to a specific line?

我可以在 exclipse 中打开一个文件,但是是否有任何语法可以跳转到特定行?

VI can do this by

VI可以通过

vi -c LINE filename

回答by VonC

Not exactly the right answer, but for Java file, you can use the package explorer, or the outline view, useful to select a group of lines) and open the file to the line matching a Java element (class, method, variable, ...)

不是完全正确的答案,但对于 Java 文件,您可以使用包浏览器或大纲视图,这对选择一组行很有用)并将文件打开到与 Java 元素(类、方法、变量、. ..)

Eclipse open

日食打开

Once the file is already opened, CTRL+Lis the way to go to a line of the currently edited file, as Adimentions in the comment.

一旦文件已经打开,CTRL+L是转到当前编辑文件的一行的方式,正如Adi在评论中提到的那样。

回答by raho

Only tested on MARS:

仅在 MARS 上测试:

Preferences > Keys > "Open from Clipboard"

首选项 > 键 > “从剪贴板打开”

Assign key binding.

分配键绑定。

  1. Copy i.e. log entry in format Main.java:1
  2. Press chosen key binding
  3. voilà
  1. Main.java:1格式复制 ie 日志条目
  2. 按选择的键绑定

In latest Version [Oxygen] key was ctrl+shift+v

在最新版本中 [Oxygen] 键是ctrl+ shift+v

回答by krispy

Finally fixed!!

终于修好了!!

On Windows:

在 Windows 上:

eclipsec.exe -name Eclipse --launcher.openFile %USERPROFILE%\workspace\MyClass.java:50

On Linux/Mac:

在 Linux/Mac 上:

eclipse -name Eclipse --launcher.openFile ~/workspace/MyClass.java:50

回答by Bozho

  1. CTRL+SHIFT+R(Open Resource) or CTRL+SHIFT+T(Open Type, for classes only)

  2. Type the name / the start of the name / the first letters of a camel case name

  3. CTRL+L(Go to line)

  1. CTRL+ SHIFT+ R(开放资源)或CTRL+ SHIFT+ T(开放类型,仅适用于类)

  2. 输入名称/名称的开头/驼峰式名称的第一个字母

  3. CTRL+ L(转到行)

回答by ewerybody

Hmm. For me it works on Windows as simple as

唔。对我来说,它可以在 Windows 上运行,就像

eclipse.exe path\filename.ext:42


(I was actually looking for a consistent solution across IDEs.
Pycharm offers pycharm.exe path:numberas wellbut it does not seem to work :/)


(我实际上是在寻找跨 IDE 的一致解决方案
。Pycharm 也提供pycharm.exe path:number但它似乎不起作用:/)

回答by Master Yoda

Try

尝试

eclipse.exe file.txt:22 

for newer versions of eclipse, and

对于较新版本的 eclipse,以及

eclipse.exe file.txt+178

for older ones.

对于年长的人。

回答by makermarc

Continuing from @raho's response, the complete menu path is: Window -> Preferences -> General -> Keys

继续@raho的回复,完整的菜单路径是:Window -> Preferences -> General -> Keys

This won't work on c++ as far as I can tell.

据我所知,这不适用于 C++。

(I'm using Oxygen 4.7.1a)

(我使用的是氧气 4.7.1a)