Need help keymap binding a package


#1

Hi,

I would like to create three different keybinding for the following package; calc
Including these commands:

  1. Evaluates (‘alt-c’)
  2. Replace (‘alt-z’)
  3. Count (‘alt-x’)

Thank you


#2

You want one key press to perform all three commands? Please provide an example of how you want this to function.


#3

Not 1 key, three separate for all three commands.

For example:

command: “calc:evaluate”
‘alt-c’:

command: “calc:replace”
‘alt-z’:

command: “calc:count”
‘alt-x’:

I edited the OP, sorry for not being clear about it.


#4

Add something like the following to your Keymap:

'atom-text-editor:not([mini])':
  'alt-c': 'calc:evaluate'
  'alt-z': 'calc:replace'
  'alt-x': 'calc:count'

I’m not sure if I remember this correctly, but I think Microsoft advises against shortcuts using the Alt-key as only modifier (at least on Windows).

Edit: removed unbind! as suggested in follow-up


#5

The unbind! entries are unnecessary and don’t even get evaluated in your example because CSON overwrites all previous instances of the same key with the last instance of the key.


#6

You live and learn :slight_smile:


#7

Indeed, it worked like a charm without the unbind.

Thank You both. idleberg & leedohm