diff --git a/docs/customizing-atom.md b/docs/customizing-atom.md index a2e7fecb8..302faa486 100644 --- a/docs/customizing-atom.md +++ b/docs/customizing-atom.md @@ -30,8 +30,9 @@ built-in keymaps: '.editor': 'enter': 'editor:newline' -".select-list .editor.mini": - 'enter': 'core:confirm' +'body': + 'ctrl-P': 'core:move-up' + 'ctrl-p': 'core:move-down' ``` This keymap defines the meaning of `enter` in two different contexts. In a @@ -40,10 +41,9 @@ the editor to insert a newline. But if the same keystroke occurs inside of a select list's mini-editor, it instead emits the `core:confirm` event based on the binding in the more-specific selector. -By default, any keymap files in your `~/.atom/keymaps` directory are loaded -in alphabetical order when Atom is started. They will always be loaded last, -giving you the chance to override bindings that are defined by Atom's core -keymaps or third-party packages. +By default, `~/.atom/keymap.cson` is loaded when Atom is started. It will always +be loaded last, giving you the chance to override bindings that are defined by +Atom's core keymaps or third-party packages. ## Advanced Configuration diff --git a/dot-atom/keymap.cson b/dot-atom/keymap.cson new file mode 100644 index 000000000..872395168 --- /dev/null +++ b/dot-atom/keymap.cson @@ -0,0 +1,13 @@ +# User keymap +# +# Atom keymaps work similarly to stylesheets. Just as stylesheets use selectors +# to apply styles to elements, Atom keymaps use selectors to associate +# keystrokes with events in specific contexts. Here's a small example, excerpted +# from Atom's built-in keymaps: +# +# '.editor': +# 'enter': 'editor:newline' +# +# 'body': +# 'ctrl-P': 'core:move-up' +# 'ctrl-p': 'core:move-down' diff --git a/src/keymap.coffee b/src/keymap.coffee index 69525dfa7..d64b1f082 100644 --- a/src/keymap.coffee +++ b/src/keymap.coffee @@ -36,8 +36,9 @@ class Keymap @loadDirectory(config.bundledKeymapsDirPath) @emit('bundled-keymaps-loaded') - loadUserKeymaps: -> - @loadDirectory(path.join(config.configDirPath, 'keymaps')) + loadUserKeymap: -> + userKeymapPath = CSON.resolve(path.join(config.configDirPath, 'keymap')) + @load(userKeymapPath) if userKeymapPath loadDirectory: (directoryPath) -> @load(filePath) for filePath in fsUtils.listSync(directoryPath, ['.cson', '.json']) diff --git a/src/window.coffee b/src/window.coffee index 4282d2a0b..6f7ec2d0a 100644 --- a/src/window.coffee +++ b/src/window.coffee @@ -53,7 +53,7 @@ window.startEditorWindow = -> atom.packages.loadPackages() deserializeEditorWindow() atom.packages.activate() - atom.keymap.loadUserKeymaps() + atom.keymap.loadUserKeymap() atom.requireUserInitScript() atom.menu.update() $(window).on 'unload', ->