-
Notifications
You must be signed in to change notification settings - Fork 58
Overriding keybindings is unintuitive and difficult #110
Comments
I can't actually get I ended up overriding |
We know that the system is confusing (see #49, #33, atom/atom#6718, among others). We continue to discuss ideas of how to make the keybinding system more approachable while maintaining the flexibility and power of the current system.
If a keybinding is winning out over your desired one, such as
So, continuing the example, you need to add this to your 'atom-workspace atom-text-editor:not([mini])':
'cmd-shift-d': 'atomic-rtags:follow' Keep in mind that you should only have one instance of each selector in your |
Hi @lee-dohm , following your instruction, I found that in preference panel -> keybinding, for the same key and selector, I can see the same key mapped to two entries. Is that okay as long as the user (I) defined one wins over the plugin/system one? |
@dragonxlwang Yes, it is. For example, here's the list of what is mapped to Tab on my installation of Atom: We designed the keybinding system so that one could use the same key (or key combination) in different areas of the application or in the same area of the application for different things. |
thanks! But what do you mean by
?? Shouldn't the behavior in one selector for the same key to be deterministic? |
While it is not quite deterministic, it is cooperative. In the keybinding documentation it covers how multiple keybindings can be bound to the same key and how they cooperate so that if the first key's job isn't applicable, it defers to the next one. Notice that I have, for the exact same selector (in red), three different packages (in blue, green, and orange) mapping four different commands to Tab: |
that makes lots senses. Thanks for explaining! just want to be sure, while reading this section in the link:
Does it ensure that user defined key always take more priority than others? |
No, CSS specificity states that all things being equal, the last one to be loaded wins. But there are plenty of things that can cause a built-in keybinding to override a user-specified keybinding. One of our long-standing community members, @mark-hahn, has been recommending this tutorial for learning about specificity in CSS: |
But when is the .atom/keymap.cson loaded? I hope it would be loaded last. It seems so... |
Yes it is, but that doesn't override the specificity rules. It is treated exactly as CSS rules are treated in a web page. |
Thanks @mark-hahn |
The keybinding system has been confusing an unintuitive for me since the day I installed Atom years ago, and for everyone I've introduced to Atom as well. It's extremely frustrating how difficult it is to accomplish the simplest and most common of tasks: changing a key from one behavior to another. This morning (on Atom 1.7.3) I wanted to change
But nope, this has the bewildering and completely undesirable result of running both my keybinding and the default keybinding at the same time: Even though the keybinding I defined is highlighted in green, both it AND the grey keybinding are running simultaneously when I press In order to finally get this simple change working, I had to not only unset the current keybindings in their selector, but then come up with a different selector to set my keybindings:
I love Atom, but this keybinding nonsense is endlessly frustrating. Even if this is just a one-off bug, or a mistake on my part, I have experiences like every single time I try to change keybindings... which I have to try more often than I should, since updates to Atom frequently make changes to the default keybindings I've gotten used to, forcing me to override them. |
@courthead your issue is because the MRU keybinding is actually |
Thanks for the info. Turns out you have to use Anyway, this is just another example of keybindings being extremely difficult to use. What is |
The missing |
+1 The current system is more than confusing, even for experienced CSS developers like me. The simple reason is that you have to know exactly what the most specific rule is in order to override it. I know know that there's a key resolver, but this wasn't intuitive either. In most other editors, you just have a GUI where you can set key bindings to your liking. |
I was trying to do exactly the change @courthead wanted and I got as far as getting the code below done:
Figuring out that a Key Resolver existed show me that my rules wasn't being executed, but I had to get to issue tracker to find out what I wanted and even after that, I was only able to do it because someone wanted exactly the same thing. Googling returns multiple issues and no place seems authoritative about how to learn about this at all. Can we at least think of providing some commented examples in That would alleviate the pain. |
I was trying to do the exact same thing as @courthead and @thiagocmoraes, and after an hour finally figured out that I needed to put:
BEFORE
in keymap.cson. It actually turns out that anything I put after the 'atom-text-editor' rules gets ignored, I think. Why?? WHY?? I can't believe spent a whole hour on this T_T |
+1000 |
👍 It is very difficult to do even the most basic keybinding overrides. I shouldn't even have to be looking this up and I still can't actually even figure it out. |
I moved to atom from ST2. I've been stuck at trying to change my key binding for ctrl-up and ctrl-down (scroll up/down line by line) for the past hour, and still can't get it to work! Is there someone who's been able to change the keybinding for this successfully? |
The keybinding story sucks really hard. Having tried numerous combinations, Not being able to copy-paste from the keybinding resolver pop-up doesn't help. Please at least give us |
Hey, I hear you guys. I'm currently focused on other pain points but this is on my radar to improve. I originally designed the selector based system in an attempt to make things flexible in the face of different packages written by different people interacting in the same DOM. It may be too flexible. It's going to take some thinking about how to extend it with a better user interface or replace it in a way that preserves backward compatibility. In the meantime, sorry for the sucky experience. I don't know what else to say right now other than I care but can't drop everything this second to fix it. If people want to start discussing proposals for how this should ideally work, I'm all ears. |
The worst part is the bug in cson that it doesn't throw an error when you On Fri, Aug 26, 2016 at 2:02 PM, Nathan Sobo [email protected]
|
Thanks for replying @nathansobo! I think the system needs to be primarily focused on the 99% use-case: overriding some existing keybinding with a new one. That should be easy, intuitive, and reliable for anyone to do, without requiring users to:
Ideally, it would be as simple as |
We're taking the advice of some people on this thread in atom/atom#12760, which always gives precedence to user bindings regardless of selector specificity and displays errors when a keymap contains duplicate keys. I'm hoping that these changes make |
@JD719 your comment was deleted as a violation of the Atom Code of Conduct as it is insulting or derogatory. You may consider this an official warning. |
Does not work for meI have to admit that neither:
... as I am trying to apply same disabling scheme for more than one keybinding. Looks like there is no solution or workaround for that. I'm stuck... Couple of ideas:
Settings should be saved automatically and could be fine-tuned by hand like currently (v1.12.7) - this edit your keymap file option should also remain for those who are familiar with it. Others who are not familiar, could be in one day when learning what program has been written when changing keybindings via GUI. |
FYI I think changing user keymap settings as the equivalent of an However, for me the not loading of duplicate keys was a breaking change. The error also does not specify the offending line member, which makes it very difficult to track down what the actual error is (I was using that key in quite a few different selectors). Furthermore the docs at a glance lead you to believe that 'overloading keybindings' is something that is supported, and only in the fine print does indicate that Atom does support executing two commands from a single keybinding (though there still seem to be contradictory statements). About an hour spent debugging until stumbling across this issue and reading through the intents of the change. Thank you for the great editor, just sharing my poor experiences with this. Having the error show line number, or even link to the PR, an item in the change log or this issue would have been very helpful. |
Atom never loaded duplicate keys* (the last one would win priority). It just wasn't obvious until the error notification was added. If you could please open an issue on atom/atom asking for the line number to be added to the notification, that would be great. * Assuming that you meant a key as in |
Fix broken link to overriding keybindings
|
Thanks! Fixed in the original. |
Had the same issue as @courthead, and took a solid 20 minutes to dig enough to find that I needed to also unset the |
We have another method of choosing the behavior of Ctrl+Tab that doesn't require any knowledge of customizing keybindings seen in the Atom FAQ here: https://discuss.atom.io/t/i-want-ctrl-tab-to-work-like-it-used-to-how-do-i-do-that/28639 |
I think the best solution for this problem would be to simply change the default snippet for "key" to something else that takes higher priority over all native key bindings everywhere. Instead of simply 'body'. That way, any new keybinding added in keymap.cson using the snippet (I assume that's how most people add their first hotkeys) will always override all else by default. As opposed to the current behavior, where new keybindings just added by new users might just be lower priority than something else. Problems could arise from overriding a native keybinding you might later want. But that's a far easier problem to find/debug/fix than the current one. The default comments on keymap.cson already suggests using the Keybind Resolver to look for conflicts. |
For anyone else struggling here, I created this package which automatically removes any keybindings (including those from Atom's core) that conflict with what you set in 'keymap.cson': https://atom.io/packages/keymap-control Hope this helps. |
@hanslivingstone just installed it, so far so good! I was having trouble when atom decided it wanted ctrl-l but i had it for switching to a pane on the right. |
I want to bind
cmd-shift-d
toatomic-rtags:follow
, but it's stuck aseditor:duplicate-lines
. The former is defined asatom-workspace atom-text-editor
, whereas the latter is defined asatom-workspace atom-text-editor:not([mini])
. Why does my custom keybinding not override the built-in one? (Yes, I've discovered that the technical answer is "because its context is more specific".) I feel like this should be easy for me to remedy by myself without reading through issues on Github.The only solution of which I am aware is to track down every usage of the offending shortcut by using the keybinding resolver, click on it to open the file it's in, search through that file to find the keybinding (because the link doesn't take you to the relevant line), copy and paste its context into my user keymap, and bind the key to
!unset
. Then, if ever any package rebinds this shortcut, I also have to remember and rerun these steps for that shortcut as well. Is this the correct approach? Or is there some simple easy way that I just can't figure out?Thanks!
The text was updated successfully, but these errors were encountered: