tomsabin
tomsabin

Reputation: 265

Atom - subword navigation key bindings

In my keymap.cson file I have the following:

'atom-text-editor':
  'ctrl-left': 'editor:move-to-previous-subword-boundary'
  'ctrl-right': 'editor:move-to-next-subword-boundary'

However, my editor does not pick up these new bindings (even after restarting). Also the default keybindings for these two (ctrl-alt-X) does not work either.

I'm using Atom 1.0.2, with all core packages.

Upvotes: 4

Views: 431

Answers (1)

Nick Farina
Nick Farina

Reputation: 4860

This is exactly what I added to my keycap.cson file to make this work:

'atom-text-editor':
  'ctrl-left': 'editor:move-to-previous-subword-boundary'
  'ctrl-right': 'editor:move-to-next-subword-boundary'
  'ctrl-shift-left': 'editor:select-to-previous-subword-boundary'
  'ctrl-shift-right': 'editor:select-to-next-subword-boundary'

Also realize that keymap.cson is in CSON format. Just like JSON, you can't "append" to keys in the file by writing them twice. For example, if you wrote this:

'atom-text-editor':
  'ctrl-left': 'editor:move-to-previous-subword-boundary'
  'ctrl-right': 'editor:move-to-next-subword-boundary'

...later in the file...    

'atom-text-editor':
  'cmd-l': 'go-to-line:toggle'

Then your subword shortcuts will be overwritten by the go-to-line shortcut. The internal CSON parser will not "merge" the values of the duplicate atom-text-editor keys.

Upvotes: 3

Related Questions