Keyboard shortcuts with prefixes


#1

Hello all,

I am trying to make atom feel a little more like emacs, starting obviously with keyboard shortcuts. I would like to add the following mapping:

'ctrl-shift-/': 'core:undo'

So Iadded this line to keymap.cson. I saved the file and reloaded the window. Sadly the shortcut does not work. Instead once I press ctrl-shift-/ (tapping and holding ctrl, then shift, then tapping /) the editor toggles line comments. The keybinding resolver tells me that this is due a "ctrl-/": "editor:toggle-line-comments" binding in a bundled linux.cson.

The problem seems to be that one binding is a prefix / subbinding of another one. So I have the following questions:

  • Is it possible in atom to assign different actions to keybindings where one binding is the prefix of another one?
  • Is it possible to unbind shipped key bindings (removing them from atom)?

#2

Mind sharing your keymap.cson with us?

Is it possible in atom to assign different actions to keybindings where one binding is the prefix of another one?

I think you’re thinking of this wrong. ctrl-/ is not a “prefix” of ctrl-shift-/. They’re completely different sequences. Are you pressing all three keys at the same time?

Is it possible to unbind shipped key bindings (removing them from atom)?

Yes.


#3

Well, my keymap is pretty vanilla so far:

# Your keymap
#
# Atom keymaps work similarly to style sheets. Just as style sheets use
# selectors to apply styles to elements, Atom keymaps use selectors to associate
# keystrokes with events in specific contexts. Unlike style sheets however,
# each selector can only be declared once.
#
# You can create a new keybinding in this file by typing "key" and then hitting
# tab.
#
# Here's an example taken from Atom's built-in keymap:
#
# 'atom-text-editor':
#   'enter': 'editor:newline'
#
# 'atom-workspace':
#   'ctrl-shift-p': 'core:move-up'
#   'ctrl-p': 'core:move-down'
#
# You can find more information about keymaps in these guides:
# * http://flight-manual.atom.io/using-atom/sections/basic-customization/#_customizing_keybindings
# * http://flight-manual.atom.io/behind-atom/sections/keymaps-in-depth/
#
# If you're having trouble with your keybindings not working, try the
# Keybinding Resolver: `Cmd+.` on macOS and `Ctrl+.` on other platforms. See the
# Debugging Guide for more information:
# * http://flight-manual.atom.io/hacking-atom/sections/debugging/#check-the-keybindings
#
# This file uses CoffeeScript Object Notation (CSON).
# If you are unfamiliar with CSON, you can read more about it in the
# Atom Flight Manual:
# http://flight-manual.atom.io/using-atom/sections/basic-customization/#_cson

#'ctrl-x ctrl-l': 'editor:lower-case'
#'shift shift': 'fuzzy-finder:toggle'

'*':
  'ctrl-shift-/': 'core:undo'

#4

OK, this is embarassing. I should have bound 'ctrl-/': 'core:undo' because / implies that shift is pressed at the same time (although ctrl-shift-7 does not work) … This is actually consistent with emacs.


#5

Hi. I was just about to tell you that your share keybinding does work. Now I see you are looking for something else. Case closed?


#6

Okay, that’s important information: you’re using a completely different keyboard. I don’t have to press shift to access /.