How can I jump to class/method definition in Atom text editor?

Atom Editor

Atom Editor Problem Overview


Is there an easy way to do this? On Aptana I used Control+click and I wish there was a way to do something similar on Atom.

Atom Editor Solutions


Solution 1 - Atom Editor

I had the same issue and atom-goto-definition (package name goto-definition) worked like charm for me. Please try once. You can download directly from Atom.

This package is DEPRECATED. Please check it in Github.

Solution 2 - Atom Editor

I believe the problem with "go to" packages is that they would work diferently for each language.

If you use Javascript js-hyperclick and hyperclick (since code-links is deprecated) may do what you need.


Use symbols-view package which let your search and jump to functions declaration but just of current opened file. Unfortunately, I don't know of any other language's equivalent.

There is also another package which could be useful for go-to in Python: python-tools

As of May 2016, recent version of Atom now support "Go-To" natively. At the GitHub repo for this module you get a list of the following keys:

  • symbols-view:toggle-file-symbols to Show all symbols in current file
  • symbols-view:toggle-project-symbols to Show all symbols in the project
  • symbols-view:go-to-declaration to Jump to the symbol under the cursor
  • symbols-view:return-from-declaration to Return from the jump

screenshot

I now only have one thing missing with Atom for this: mouse click bindings. There's an open issue on Github if anyone want to follow that feature.

Solution 3 - Atom Editor

I also had the same problem. And I find the solution:

CTRL+ALT+G

Update:

Thanks to @Joost, install Atom package python-tools to make it work

Solution 4 - Atom Editor

The functionality is already present in atom via the Symbols View package you don't need to install anything.

The command you are searching for is symbols-view:go-to-declaration (Jump to the symbol under the cursor) which is bound by default to cmd-alt-down on macOS and ctrl-alt-down on Linux.

just note that it will work only if you will have generated tags for your project, either via this package or via ctags (exuberant or not)

Solution 5 - Atom Editor

This feature has been built-in into Atom editor (see: symbols-view package), but you need to generate ctags symbols file for your project GH-9, GH-20.

To do that, install ctags command (e.g. brew install ctags on macOS), then:

  1. Append, link or copy ctags-config to your ~/.ctags, example on macOS:

     ln -vs "$(find /Applications/Atom.app -name ctags-config -print -quit)" ~/.ctags
    
  2. Go to your project folder and run:

     cd your/project/directory
     ctags -R .
    
  3. Restart Atom editor.


Alternatively you can use symbol-gen package to generate ctags symbols file for your project based on the options found in .ctags file. You can install it from Atom Package Manager by: apm install symbol-gen. Then hit CMD-Alt-G to generate tags file for your project.


After following above, you can use Go To Declaration option from the context menu.

On macOS you can use also use the following keyboard shortcuts:

  • CMD-R to jump to a function/method in the current ,editor

  • Alt-CMD-Down to go to declaration.

Solution 6 - Atom Editor

To solve this, you'll need to install only 2 packages. Follow the steps below.

  1. Open atom, go to Packages(top bar) --> Settings View --> Install Packages/Themes.

  2. Type "goto" in the search field and click the packages button on the right.

  3. Install both "goto(1.8.3)" and "goto-definition(1.1.9)", or later versions. Make sure both of them are enabled after download.

  4. If necessary, you can restart atom (for some people).

  5. It should be able to work now. Right-Click on the method/attr/whatever, then select "Goto Definition"

Solution 7 - Atom Editor

Check out goto package:

> This is a replacement for Atom’s built-in symbols-view package that > uses Atom’s own syntax files to identify symbols rather than ctags. > The ctags project is very useful but it is never going to keep up with > all of the new Atom syntaxes that will be created as Atom grows. > > Commands: > > - cmd-r - Goto File Symbol > - cmd-shift-r - Goto Project Symbol > - cmd-alt-down - Goto Declaration > - Rebuild Index > - Invalidate Index

Link here: https://atom.io/packages/goto (or search "goto" in package installer)

Solution 8 - Atom Editor

For Typescript users, the "atom-typescript" package adds a typescript aware symbols view, you can trigger it with Cmd+R, and it works great to jump to methods-

https://atom.io/packages/atom-typescript#alternative-to-symbols-view

Solution 9 - Atom Editor

Use atom-ctags as a package for C language with all things you need:

  • Generated ctags for your project. Auto-complete.
  • Go to declaration: Ctrl+Alt+Down and Alt+Click by default.
  • There are customizable options for Click action.

Solution 10 - Atom Editor

As of November 2018 the package autocomplete-python offers this functionality with this key combo:

Ctrl+Alt+G

with mouse cursor on the function call.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionandromedaView Question on Stackoverflow
Solution 1 - Atom EditorSitam JanaView Answer on Stackoverflow
Solution 2 - Atom EditorcortopyView Answer on Stackoverflow
Solution 3 - Atom EditorQ-bartView Answer on Stackoverflow
Solution 4 - Atom EditorEdoardoView Answer on Stackoverflow
Solution 5 - Atom EditorkenorbView Answer on Stackoverflow
Solution 6 - Atom EditorAllan MwesigwaView Answer on Stackoverflow
Solution 7 - Atom EditorAbramView Answer on Stackoverflow
Solution 8 - Atom EditorchrismarxView Answer on Stackoverflow
Solution 9 - Atom EditorAleksandr FadeevView Answer on Stackoverflow
Solution 10 - Atom EditorgccallieView Answer on Stackoverflow