Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ctrl+Click on a function name in Atom editor and jump into it

I've been trying to think of a better way to title this question, but unfortunately I have no idea how to explain it. Also I haven't found this on stack overflow (for the same reason stated above).

In Eclipse, I used to Ctrl+Click in the name of a method call (in java). And my cursor would jump in to the definition of my method function.

Question 1: Does anyone know the name of this behavior? I mean, maybe it's called function jumping or something like that.

Also I was searching for a plugin like this in Atom editor. Because I've tried to use this a lot of times (bad habits) and didn't work.

Question 2: Name of the plugin to do this in Atom?

Don't know if it helps, but I'm coding in JavaScript at the moment in Atom editor.

like image 527
Jose Serodio Avatar asked Mar 04 '16 18:03

Jose Serodio


People also ask

How can you enable control click to go to a definition of a function method?

Once installed, you can use ctrl-shift-r over the word (function/method, variable etc) to bring up a list of where that method/function is defined (includes line # & filepath). You can then click on the list item & it will jump you to the definition.

How do I open command prompt in Atom editor?

In that welcome screen, we are introduced to probably the most important command in Atom, the Command Palette. If you press Ctrl+Shift+P while focused in an editor pane, the command palette will pop up.


3 Answers

As the other answer noted, alt-click over a method/function name can jump you directly to where it was originally defined. It works within the same file, but it doesn't seem to work across files.

The closest Atom editor package I've found for javascript which allows you to jump to function/method definitions across files is called TernJS.

Once installed, you can use ctrl-shift-r over the word (function/method, variable etc) to bring up a list of where that method/function is defined (includes line # & filepath). You can then click on the list item & it will jump you to the definition.

Here is a video I made containing an example of using this atom package. http://www.youtube.com/watch?v=cFAzqvYoHJs&t=11m58s

like image 51
Clifford Fajardo Avatar answered Oct 14 '22 17:10

Clifford Fajardo


To answer your first question this 'behavior' is knows as 'go to definition', or 'jump to definition'.

To answer your second question some packages you could perhaps take a look at would be,

  • 'goto-definition'
  • 'code-peek'

I find these help a bit but still don't achieve the standards that I would fully like. I wanted something similar to the Intellij IDEA ctrl + click.

I find myself using the ctrl + shift + f to search the entire project for the related files of the thing I'm searching for. Then I find the particular file i'm looking for and shazam! I've got what I came to get. This particular method works best for me.

I know its not exactly what your looking for but this is the best thing I've found so far to achieve something similar to what we both seem to be looking for. Hope this helps a bit, happy coding...

like image 34
C.Gadd Avatar answered Oct 14 '22 19:10

C.Gadd


Currently this behavior is blocked by multiple cursors feature. The closest you can get is "ctrl-alt-shift-d" + atom-ternjs

like image 26
Vanuan Avatar answered Oct 14 '22 17:10

Vanuan