Disable atomic soft tabs behaviour on a shortcut - fast solution?


Mainly because i want to use atom-sublime-select package, and occasionally to be able to select somewhere in the middle of the indents (though i use spaces) - is there a way in Atom to set this behaviour on a shortcut e.g. “while key_press_down: Alt”
(which for me the shortcut is also Alt for the atom-sublime-select package) this will make it perfect to either select with the plugin or if i only want to select in the middle of the indent sometimes.

link to the git for the atom-sublime-select package where i posted an issue regarding this (with pictures):

Atomic soft tabs is a great feature and i’d like to keep it, though i think it would be really nice to be able to turn it off on a key press down


I don’t believe Atom supports setting keybindings based on whether a key is held down or not. If that’s what you’re asking for, and sublime-select supports it, then you’ll need to look at how they implement it.

If you simply want to assign a keybinding to the setting though, that’s much easier:
Open your init.coffee file and add the following code snippet:

atom.commands.add 'atom-text-editor', 'custom:toggle-atomic-soft-tabs': (event) ->
  if atom.config.get('editor.atomicSoftTabs')
    atom.config.set('editor.atomicSoftTabs', false)
    atom.config.set('editor.atomicSoftTabs', true)

Then open your keymap and add the following:

'atom-workspace atom-text-editor':
  'your-keybinding-here': 'custom:toggle-atomic-soft-tabs'

Reload Atom and try it out.

Some things to note:

  1. If your keymap already contains an atom-workspace atom-text-editor segment, then only copy/paste the actual keybinding and not the selector (see the warning at the top of the keymap page I linked).
  2. The keybinding must have a non-modifier key in it to work. For example, alt will not work, but alt-c will. This is a limitation of the keymap system. If you want to use only modifier keys, then you’ll have to look into a custom solution in your init script.
  3. Feel free to name the command whatever you want, all that actually matters is you have a colon somewhere in there.


@Wliu Thank you for pointing me in the right direction

I decided to go the other way and hack the package, because with it i get additional feature to disable Atomic Soft Tabs on key state. If anyone else needs to implement it, here is what i did:

(solution in the comments)