Skip to content

Instantly share code, notes, and snippets.

@martpie
Last active October 7, 2021 09:41
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martpie/532134a7390eea142792 to your computer and use it in GitHub Desktop.
Save martpie/532134a7390eea142792 to your computer and use it in GitHub Desktop.
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
Copy link

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
Copy link

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

@dominikkucharski
Copy link

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