18

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

VI can do this by

vi -c LINE filename
powtac
  • 40,542
  • 28
  • 115
  • 170
  • I can not understand what you mean by syntax,but keyboard shortcut CTRL+L will open a popup and you can enter line number there. – Adisesha Feb 19 '10 at 11:03
  • @Adi: CTRL+L would work only when "Editing Text", i.e if the file is *already* opened... – VonC Feb 19 '10 at 11:58
  • @Von He mentioned 'I can open a file in eclipse', I guess he already know how to open. – Adisesha Feb 19 '10 at 12:39
  • 3
    @Adi: I interpreted it as: "how to open file (*not yet* opened) *directly* to a specified line. – VonC Feb 19 '10 at 13:18

7 Answers7

42

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, ...)

Eclipse open

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

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 13
    @abel: courtesy of http://www.faststone.org/FSCaptureDetail.htm FastStone Capture (not free, but worth every penny) – VonC Jan 11 '11 at 16:01
  • 34
    That screenshot is diabolical –  May 21 '13 at 14:20
  • 10
    @VonC you're telling us that you actually paid for the $45 family license so you can take prettier screenshots? – krispy Apr 19 '16 at 16:04
  • 3
    @krispy It was not 45$ at the time I purchased a license some 6 or 7 years ago, but it was worth every penny for the usage I had and still have of this software. – VonC Apr 19 '16 at 17:27
11

Finally fixed!!

On Windows:

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

On Linux/Mac:

eclipse -name Eclipse --launcher.openFile ~/workspace/MyClass.java:50
krispy
  • 1,244
  • 14
  • 19
10

Only tested on 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à

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

Sunil Kanzar
  • 1,244
  • 1
  • 9
  • 21
raho
  • 131
  • 2
  • 8
  • 2
    This should be the accepted solution as its inbuilt into eclipse and allows for easy navigation fro m a log stack trace to the class file – Clyt Mar 19 '18 at 10:20
8
  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)

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140
3

Hmm. For me it works on Windows as simple as

eclipse.exe path\filename.ext:42


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

ewerybody
  • 1,443
  • 16
  • 29
2

Try

eclipse.exe file.txt:22 

for newer versions of eclipse, and

eclipse.exe file.txt+178

for older ones.

Master Yoda
  • 176
  • 1
  • 8
0

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

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

(I'm using Oxygen 4.7.1a)

makermarc
  • 1
  • 2