Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set a shortcut in Atom editor for Go To Definition using go-plus

Tags:

atom-editor

How can I set a shortcut in Atom editor for Go To Definition using go-plus. Thanks for your help in advance.

like image 988
Sandeep Avatar asked Sep 08 '15 17:09

Sandeep


People also ask

How do I create an Atom shortcut?

Simply hit **ctrl + ** ( ctrl + backtick`) and you will get a cheatsheet on your screen immediately. Run apm install atom-shortcuts to install the package.

How do you find the function declaration of an Atom?

CMD - R to jump to a function/method in the current ,editor. Alt - CMD - Down to go to declaration.

How do I turn on autosave in Atom?

Autosave package This package is disabled by default and can be enabled via the autosave. enabled config setting or from the Autosave section of the Settings view (OS X: cmd-,, Windows & Linux: Ctrl-,).


1 Answers

By default, the go-plus package uses Alt+Cmd+G to trigger the Go To Definition binding (as can be seen here). This binding will only work in files that use the Go grammar. Since Cmd is only available on Mac OS X, I don't know what keybinding other operating systems will use by default.

To redefine the keybinding, do the following:

  • Open the Atom Preferences, select the Keybindings section.
  • In the Search field, type 'go' to filter the list of keybindings.
  • Click the Copy icon next to the golang:godef keybinding.
  • Click the your keymap file link at the top.

Atom Keybindings

This will open your keymap.cson file. Go to the end of the file and paste the copied content:

'atom-text-editor[data-grammar="source go"]:not(.mini)':
  'alt-cmd-g': 'golang:godef'

Edit the keybinding to your liking and safe the file.

To verify the new keybinding, open the Key Binding Resolver view by selecting the Packages > Key Binding Resolver > Toggle menu entry. Open a Go file and press the keybinding you assigned, then watch the Key Binding Resolver view to see any conflicts.

like image 167
nwinkler Avatar answered Sep 28 '22 12:09

nwinkler