Remap keys


#1

Hi. Just changed from Emacs to Atom. I am using a danish keyboard on a mac, where [] are on Alt-8 and Alt-9 and {} on Shift-Alt-8 and Shift-Alt-9. In Emacs I mapped the æø and ÆØ keys to {} and [] for easier access, but I can’t figure out how to do this in Atom (keeping the normal functionality of the character).

Anyone?


#2

What have you tried?


#3

I have tried snippets.cson, but then I have to type TAB to expand it.

I have tried keymap.cson, but could not get it working.

I have been using Emacs and programmed Emacs-Lisp for +30 years. There must be a way to do it :slight_smile:

Do you have any ideas?


#4

You can make a command in init.coffee:

atom.commands.add 'atom-text-editor', 'custom:insert-lower-dipthong', ->
  atom.workspace.getActiveTextEditor().insertText("æ")

Add that to a keybinding and make three more of them and you should be golden.


#5

Thanks, you really made my day :wink:

Changed your code in init.coffee:

atom.commands.add 'atom-text-editor', 'custom:insert-curly-left', ->
  atom.workspace.getActiveTextEditor().insertText("{")

atom.commands.add 'atom-text-editor', 'custom:insert-sharp-left', ->
  atom.workspace.getActiveTextEditor().insertText("[")

I added this in keycap.cson

'atom-text-editor':
  'æ': 'custom:insert-curly-left'
  'Æ': 'custom:insert-sharp-left'

Now works like I wanted !


Remap some keys
#6

Yes, what I said except the other way around. :slight_smile:


#7

Now my only problem is when I (rarely) have to type the æ character. In Emacs I could just Ctrl-q-æ.

But having the { key as just one stroke is far better than Alt-Shift-( where you have to use three fingers :wink:

I hope others with language specific keyboards find this solution.

Thanks again.