Changing the Keymap for Tree View:Toggle?


#1

I’m getting started with customizing the Atom Editor and have gotten stumped attempting to change the key mapping for Tree View:Toggle.

I put this in my user keycap.cson file:

'.editor':
     'ctrl-t': 'Tree View:Toggle'```

But it doesn't work.

Looking at Preferences->Keybindings I see it listed as I'd expect:

```ctrl-t   Tree View:Toggle    User    .editor```

What did I do wrong?

#2

I checked the Keybinding Resolver (very clever, I just learned about using cmd-.). I see that my keybinding is firing and goes first above the editor:transpose command from the base.json keycap. So it seems like I’m on the right track, but still missing something.


#3

The command is tree-view:toggle


#4

Hmmm.

Even with

'.editor':
     'ctrl-t': 'Tree View:Toggle'

Keyboard Resolver showed it as firing.

'.editor':
     'ctrl-t': 'tree-view:toggle'

fires, too. But neither work.

Is ‘.editor’ the correct scope?


#5

If you look at the screenshot, the scope that the standard keymap uses is .platform-darwin. Have you tried using that?


#6

Yes. And that doesn’t work. It doesn’t even trigger in Keyboard Resolver.


#7

Check this post for links to information on keymap cascade order:

And search on the various keymap topics here. I’m certain you’ll figure it out.


#8

For all who search a working solution, here are my lines:

'.platform-win32 atom-text-editor:not([mini])':
  'alt-q': 'tree-view:toggle'
'.platform-linux atom-text-editor:not([mini])':
  'alt-q': 'tree-view:toggle'
'.platform-darwin atom-text-editor:not([mini])':
  'alt-q': 'tree-view:toggle'

Important: If you have an error or typo someone else in the keymap.cson the whole things are broken.


#9

@jensklose solution worked for me. Thanks!

A minor thing, when I toggle the Tree View, once it appears, it is set as an active panel, not panel with code.

Does anybody know, is there a way to toggle the Tree View without making it active? Like clicking on the menu bar option does currently. I would like to keep typing code after toggling.