Skip to content

Instantly share code, notes, and snippets.

@martpie

martpie/keymap.cson

Last active Mar 15, 2019
Embed
What would you like to do?
Get emmet-atom working fine with Atom and autocomplete-plus
# Will make autocomplete trigger with 'enter' instead of 'tab'
'atom-text-editor:not(mini) .autocomplete-plus.autocomplete-suggestion-list':
'tab': 'unset!'
'enter': 'autocomplete-plus:confirm'
# Use 'expand-abbreviation' instead of 'expand-abbreviation-with-tab' for tab keybinding
'.pane .editor:not(.mini)':
'tab': 'emmet:expand-abbreviation'
@jordanbtucker

This comment has been minimized.

Copy link

@jordanbtucker jordanbtucker commented Mar 18, 2015

If you want to use Tab with Autocomplete and Emmet, this is what I do.

Install autocomplete-plus and autocomplete-snippets (and whatever other autocomplete-plus provider packages you want):

apm install autocomplete-plus autocomplete-snippets

Next, edit your keymap.cson file (File > Open Your Keymap) and paste this at the bottom:

# Stop emmet from hijacking tab from snippets and autocomplete
'atom-text-editor.autocomplete-active[data-grammar="text html basic"]:not([mini]), atom-text-editor[data-grammar~="jade"]:not([mini]), atom-text-editor[data-grammar~="css"]:not([mini]), atom-text-editor[data-grammar~="sass"]:not([mini])':
  'tab': 'autocomplete-plus:confirm'

This allows you to still use Tab with Emmet, but only when the autocomplete popup is not open.

  • If you start typing, and autocomplete pops up, you can press Tab for autocomplete.
  • If autocomplete doesn't pop up (because there are no matches), you can press Tab and get an Emmet expansion.
  • If autocomplete does pop up, but you want to use an Emmet expansion, you can press Esc to close the autocomplete popup and then press Tab for an Emmet expansion.

The reason you need to install autocomplete-snippets is because Emmet takes precedence over snippets, but if you have an autocomplete popup open and this keymapping in place, then the snippet will take precedence.

The best of both worlds.

@Harry-Harrison

This comment has been minimized.

Copy link

@Harry-Harrison Harry-Harrison commented Feb 15, 2016

So, I tried this and it actually disables the tab key altogether unless there's an abbreviation to be had...

@dominikkucharski

This comment has been minimized.

Copy link

@dominikkucharski dominikkucharski commented Jan 5, 2017

It works great! Thank you for this solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.