Skip to content

Instantly share code, notes, and snippets.

@mxstbr
Last active October 20, 2024 20:44
Show Gist options
  • Save mxstbr/361ddb22057f0a01762240be209321f0 to your computer and use it in GitHub Desktop.
Save mxstbr/361ddb22057f0a01762240be209321f0 to your computer and use it in GitHub Desktop.
Enable tab completion for JSX with Emmet in Atom

Enable tab completion for JSX with Emmet in Atom

This guide assumes you have the emmet and language-babel packages already installed in Atom

Gif of the tab completion working

  1. Open the keymap.cson file by clicking on Atom -> Keymap… in the menu bar
  2. Add these lines of code to your keymap:
'atom-text-editor[data-grammar~="jsx"]:not([mini])':
  'tab': 'emmet:expand-abbreviation-with-tab'

Now open a file with JSX code, type div.myclass, press tab and it should autocomplete to <div className="myclass"></div>! (if it's not properly syntax highlighted, select Babel ES6 JavaScript or JSX as the syntax, this won't work otherwise)

@Flaex
Copy link

Flaex commented Dec 7, 2018

Thanks a lot!!

@gjmcgough
Copy link

I love you.

@ndemianc
Copy link

Great!

@iloveip
Copy link

iloveip commented May 15, 2019

Thank you very much! I also had to install react package, but I get the following warning:

Incompatible Package Detected
language-babel has detected the presence of an incompatible Atom package named 'react'. 
 
It is recommended that you disable either 'react' or language-babel 
 
Reason:
 
The Atom community package 'react' (not to be confused 
with Facebook React) monkey patches the atom methods 
that provide autoindent features for JSX. 
As it detects JSX scopes without regard to the grammar being used, 
it tries to auto indent JSX that is highlighted by language-babel. 
As language-babel also attempts to do auto indentation using 
standard atom API's, this creates a potential conflict.

Is there anyway to turn it off?

@Analova
Copy link

Analova commented Jun 18, 2019

It is not working for me.

@appsparkler
Copy link

appsparkler commented Jun 28, 2019

This worked for me. Thanks a lot.

This is what I did:

  1. Install atom package language-babel
  2. Install atom package emmet
  3. Add the following snippet at the top of keymap.cson which is available on File > Keymap in the Atom Toolbar
'atom-text-editor:not([mini])':'tab':'emmet:expand-abbreviation-with-tab'

Good Luck...

@mauroeparis
Copy link

I love you.

@TheNuggitMan
Copy link

This is beautiful, but I cannot get the syntaxProfiles.json to work... - I tried the single quote code from first comments, but it didn't work, is there anywhere special the /emmet dir needs to reside?

@TomTom2019
Copy link

Thanks

@kqvanity
Copy link

It didn't work until the Babel ES6 JavaScript syntax was also selected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment