I want to really go into details when configuring how I will use atom
and this for me means making a concept of how to navigate, edit, … while using atom, utilizing all kinds of installed extensions and removing conflicts.
So I’d like to make it easy to show
, compare
, analyze
, update
, remove
, … existing and new keybindings, so that they fit into a usage concept that makes sense to me and that I can share and discuss with others.
There are several keybindings
extensions that are not bad, but do not cut it for me, so I’d like to come up with my own, by:
- disabeling ALL default keybindings with
https://atom.io/packages/disable-keybindings
- using my plugin to manage my
keymap.cson
to match my concept
Problem:
There are A LOT of default keybindings that come with a freshly installed atom editor and I’d like to wrap my head around them to have a starting point, AND I’d like to do that in an automated way so that it won’t break I update my atom to newer versions - or at least that i’ll be able to see conflicts (Suggestions are welcome)
My Code:
So far I just played around for the first time using atom’s “chrome developer tools” to grab all the hotkeys.
The following code will:
- grab all keybindings shown in
Settings > Keybindings
into a formatted array and sort them - grab all keybindings from
atom.keymaps.keyBindings
into a formatted array and sort them
var arr1 = []
var arr2 = []
function compare (a, b) {
var key1
var key2
for (key in a) { key1 = key }
for (key in b) { key2 = key }
if (key1 < key2)
return -1;
if (key1 > key2)
return 1;
return 0;
}
[].forEach.call(atom.keymaps.keyBindings, function (item) {
var selector = {}
var binding = {}
binding[item.keystrokes] = item.command
selector[item.selector] = binding
arr1.push(selector)
});
editor = atom.workspace.getActiveTextEditor()
atom.commands.dispatch(atom.views.getView(editor), 'settings-view:open')
atom.commands.dispatch(atom.views.getView(editor), 'application:show-settings')
setTimeout(function () {
var kp = document.querySelector('.keybinding-panel')
var empty = kp.querySelector('.scroll-view .line span')
var source = empty ?
(alert('Please delete any content in "Search keybindings" field'),[])
: kp.querySelectorAll('tbody tr');
[].slice.call(source).forEach(function (kb) {
var k = kb.querySelectorAll('.keystroke span')[1].innerHTML
var c = kb.querySelectorAll('.command')[0].innerHTML
var s = kb.querySelectorAll('.selector')[0].innerHTML
var selector = {}
var binding = {}
binding[k] = c
selector[s] = binding
arr2.push(selector)
});
arr1.sort(compare)
arr2.sort(compare)
compute(arr1, arr2)
}, 500)
function compute(keybindings1, keybindings2) {
debugger;
window.SOURCE1 = keybindings1
window.SOURCE2 = keybindings2
}