Can I unbind all ctrl-k shortcuts at once?


#1

I want to use ctrl + “ijkl” as cursor keys. It works great but there is some lag when I hit ctrl-k. I’m guessing the reason is because of the ridiculous amount of ctrl-k-1/2/3/4… shortcuts. Can I remove all of these at once in my keymap?


How to remap ctrl-k
#2

No this is not currently possible. You’ll have to remove them one by one.


#3

Can I delete them from loading? Surely there must be a file that loads all of the shortcuts when I start it? There are way to many ctrl-k shortcuts to delete them all in my keymap.cson.


#4

You could, but the change would be overwritten every time Atom updates. Changing them in the keymap.cson is the right way to do what you’re talking about.


#5

Put this in your init.coffee and reload atom once:

fs = require 'fs'
path = require 'path'

keyBindings = {}
for keyBinding in atom.keymap.getKeyBindings()
  {selector, keystrokes} = keyBinding
  continue unless keystrokes.match /^ctrl-k/
  keyBindings[selector] ?= {}
  keyBindings[selector][keystrokes] = 'unset!'
fs.writeFileSync '/home/<username>/.atom/keybindings-ctrl-k.json', JSON.stringify keyBindings

It creates a file - /home/<username>/.atom/keybindings-ctrl-k.json - containing all the keybindings starting with ctrl-k and unsets them. If your keymap is empty, you should be able to replace its contents with the contents of the generated file, if not you should merge them by hand. Be sure to change the path to your .atom directory.


#6

And here’s the result :smile:

'body':
  'ctrl-k up': 'unset!'
  'ctrl-k down': 'unset!'
  'ctrl-k left': 'unset!'
  'ctrl-k right': 'unset!'
  'ctrl-k ctrl-w': 'unset!'
  'ctrl-k ctrl-alt-w': 'unset!'
  'ctrl-k ctrl-p': 'unset!'
  'ctrl-k ctrl-n': 'unset!'
  'ctrl-k ctrl-up': 'unset!'
  'ctrl-k ctrl-down': 'unset!'
  'ctrl-k ctrl-left': 'unset!'
  'ctrl-k ctrl-right': 'unset!'
'atom-workspace atom-text-editor':
  'ctrl-k ctrl-u': 'unset!'
  'ctrl-k ctrl-l': 'unset!'
'atom-workspace atom-text-editor:not([mini])':
  'ctrl-k ctrl-0': 'unset!'
  'ctrl-k ctrl-1': 'unset!'
  'ctrl-k ctrl-2': 'unset!'
  'ctrl-k ctrl-3': 'unset!'
  'ctrl-k ctrl-4': 'unset!'
  'ctrl-k ctrl-5': 'unset!'
  'ctrl-k ctrl-6': 'unset!'
  'ctrl-k ctrl-7': 'unset!'
  'ctrl-k ctrl-8': 'unset!'
  'ctrl-k ctrl-9': 'unset!'
'.platform-win32, .platform-linux': 'ctrl-k ctrl-b': 'unset!'
'.platform-win32 .tree-view, .platform-linux .tree-view':
  'ctrl-k right': 'unset!'
  'ctrl-k l': 'unset!'
  'ctrl-k left': 'unset!'
  'ctrl-k h': 'unset!'
  'ctrl-k up': 'unset!'
  'ctrl-k k': 'unset!'
  'ctrl-k down': 'unset!'
  'ctrl-k j': 'unset!'
'.platform-win32 atom-text-editor, .platform-linux atom-text-editor':
  'ctrl-k ctrl-d': 'unset!'

#7

Very helpful! Thank you!


#8

As refered in this post, the following extension allows to unbind all ctrl-k based keybindings.