mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Merge pull request #1038 from atom/cj-add-user-keymap-file
Use `~/.atom/keymap.cson` file instead of `~/atom/keymaps` directory
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
13
dot-atom/keymap.cson
Normal file
13
dot-atom/keymap.cson
Normal file
@@ -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'
|
||||
@@ -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'])
|
||||
|
||||
@@ -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', ->
|
||||
|
||||
Reference in New Issue
Block a user