emmetio / emmet-atom

Emmet support for Atom
MIT License
764 stars 181 forks source link

Don’t overwrite built-in keybindings of Atom #86

Open J5lx opened 10 years ago

J5lx commented 10 years ago

Looking at Atom’s keybindings page, Emmet currently overwrites several keybindings of Atom’s core as well as of packages that are included in Atom by default:

Please note that I didn’t test all of them manually (and maybe I even overlooked something), but at least as long as ctrl-w remains overwritten by Emmet I don’t see any reason to put so much effort in it since I wouldn’t use Emmet (or any other package overwriting such fundamental keybindings) anyway, even though I could change them in my keymap.cson.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/2408481-don-t-overwrite-built-in-keybindings-of-atom?utm_campaign=plugin&utm_content=tracker%2F535900&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F535900&utm_medium=issues&utm_source=github).
sergeche commented 10 years ago

These shortcuts work fine in OSX — the only officially supported platform. I will create different shortcuts for other platforms a bit later.

J5lx commented 10 years ago

OK – thanks. For me it seemed like the mentioned keybindings would be overwritten on all platforms because some others had selectors containing .platform-linux, .platform-darwin or .platform-win32 which suggested the assumption that the ones that didn’t would be platform independent. But however I don’t know any Atom internals (except that it’s based on web technologies) and used only Linux and Windows yet (sitting in front of a Mac for just half an hour or so doesn’t count), so I might be wrong with it.

doingweb commented 10 years ago

Windows user here. I second the notion of putting these OSX-ideal keybindings behind a .platform-darwin selector. I love Emmet and use it everywhere I can, but having to repair all of these keybindings (many of which are second nature for the IBM PC crowd) was a seriously disruptive experience.

dominicbarnes commented 10 years ago

Yeah, I've had to uninstall the emmet plugin because it clobbers some pretty necessary keybindings. (ctrl-left/right in my case)

sergeche commented 10 years ago

@badem4o this is open source project: anyone can create a fork and contribute better keyboard shortcuts

sergeche commented 10 years ago

Just pushed v 2.1.2 with updated shortcuts (thanks @doingweb)

Antontelesh commented 8 years ago

It still overwrites default keybindings. Due to that the subword navigation is impossible. Reassigning keybindings in keymap.cson does not help. When disabling emmet plugin, keybindings start to work as expected (but no emmet :cry: )

Grawl commented 8 years ago

Years gone. Still overrides ctrl-alt-left/right on Mac. I see that there is different keymaps for platform-darwin but looks like this keymap selector is broken for me (macOS Sierra 10.12 16A270f + Atom 1.9.6).

I have to disable Emmet keybindings in plugin settings. But I want to use Emmet anyway. There is no way to redefine specific keybindings (as I see), so I disable it all, copy it all from /keymaps/emmet.cson to end of my own keymap.cson (you can open it by link in Settings → Keybindings) and redefine ctrl-alt-left/right here. Here what I have now:

# keymap.cson

# (here is some my settings)

# Emmet redefined keybindings:

'atom-text-editor:not([mini])':
  'ctrl-e': 'emmet:expand-abbreviation'
  'ctrl-shift-e': 'emmet:balance-outward'
  'ctrl-shift-0': 'emmet:balance-inward'
  'ctrl-alt-j': 'emmet:matching-pair'
  # here was 'ctrl-alt-left/right' keybindings
  'ctrl-shift-`': 'emmet:split-join-tag'
  'ctrl-shift-;': 'emmet:remove-tag'
  'ctrl-shift-y': 'emmet:evaluate-math-expression'
  'alt-up': 'emmet:increment-number-by-01'
  'alt-down': 'emmet:decrement-number-by-01'
  'ctrl-up': 'emmet:increment-number-by-1'
  'ctrl-down': 'emmet:decrement-number-by-1'
  'alt-shift-up': 'emmet:increment-number-by-10'
  'alt-shift-down': 'emmet:decrement-number-by-10'
  'ctrl-shift-.': 'emmet:select-next-item'
  'ctrl-shift-,': 'emmet:select-previous-item'
  'ctrl-shift-r': 'emmet:reflect-css-value'
  'ctrl-u': 'emmet:update-image-size'
  "ctrl-'": 'emmet:encode-decode-data-url'
  "ctrl-shift-'": 'emmet:update-tag'
  'ctrl-shift-m': 'emmet:merge-lines'
  'ctrl-alt-w': 'emmet:wrap-with-abbreviation'
  'ctrl-alt-enter': 'emmet:interactive-expand-abbreviation'

'atom-pane atom-text-editor:not([mini])':
  'ctrl-shift-/': 'emmet:toggle-comment'

# Override Enter key for specific syntaxes only
'atom-pane atom-text-editor[data-grammar~="html"]:not([mini]):not(.autocomplete-active), atom-pane atom-text-editor[data-grammar~="xml"]:not([mini]):not(.autocomplete-active)':
  'enter': 'emmet:insert-formatted-line-break-only'

# language-specific Tab triggers
# you can add more triggers by changing `grammar` attribute values
'atom-text-editor[data-grammar="text html basic"]:not([mini]), atom-text-editor[data-grammar~="angular"]:not([mini]), atom-text-editor[data-grammar~="erb"]:not([mini]), atom-text-editor[data-grammar~="jade"]:not([mini]), atom-text-editor[data-grammar~="pug"]:not([mini]), atom-text-editor[data-grammar~="css"]:not([mini]), atom-text-editor[data-grammar~="stylus"]:not([mini]), atom-text-editor[data-grammar~="sass"]:not([mini]), atom-text-editor[data-grammar~="scss"]:not([mini])':
  'tab': 'emmet:expand-abbreviation-with-tab'

# here was .platform-darwin broken selector
'atom-text-editor:not([mini])':
  'cmd-shift-e': 'emmet:expand-abbreviation'
  'ctrl-d': 'emmet:balance-outward'
  'alt-d': 'emmet:balance-inward'
  'ctrl-right': 'emmet:next-edit-point'
  'ctrl-left': 'emmet:prev-edit-point'
  "cmd-shift-j": 'emmet:split-join-tag'
  "cmd-'": 'emmet:remove-tag'
  'cmd-shift-y': 'emmet:evaluate-math-expression'
  'ctrl-alt-up': 'emmet:increment-number-by-01'
  'ctrl-alt-down': 'emmet:decrement-number-by-01'
  'ctrl-alt-cmd-up': 'emmet:increment-number-by-1'
  'ctrl-alt-cmd-down': 'emmet:decrement-number-by-1'
  'ctrl-alt-cmd-shift-up': 'emmet:increment-number-by-10'
  'ctrl-alt-cmd-shift-down': 'emmet:decrement-number-by-10'
  'ctrl-shift-right': 'emmet:select-next-item'
  'ctrl-shift-left': 'emmet:select-previous-item'
  'cmd-shift-r': 'emmet:reflect-css-value'
  'ctrl-i': 'emmet:update-image-size'
  "ctrl-shift-i": 'emmet:encode-decode-data-url'
  'ctrl-shift-u': 'emmet:update-tag'
  'cmd-shift-m': 'emmet:merge-lines'
  'ctrl-w': 'emmet:wrap-with-abbreviation'
  'alt-cmd-enter': 'emmet:interactive-expand-abbreviation'

# here was .platform-darwin broken selector
'atom-pane atom-text-editor:not([mini])':
  'cmd-/': 'emmet:toggle-comment'

Also I added pug after Jade in language-specific Tab triggers.

pabloab commented 7 years ago

Finally found here the extremely annoying bug: emmet overriding on Linux and Windows ctrl-u, the Atom default keybinding to undo last ctrl-d selection (find-and-replace:select-undo).