Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change block comments for JSX in webstorm

In webstorm, jsx has all the same colors & stylings as javascript, which is great. However, the block comments don't adjust to jsx /* */ vs. {/* */}.

I have tried removing *.jsx as a registered javascript pattern in the File Types preferences & making jsx its own file type, but then I lose all the custom colors & styling. Is there a way to adjust the block comment characters on a per-pattern basis while having the styling refer to the pure javascript rules?

like image 774
Matt K Avatar asked Oct 22 '15 22:10

Matt K


People also ask

How do I comment multiple lines in JSX?

Multi-line comments start with /* and end with */ . Any text between /* and */ will be ignored by JavaScript.

How do you comment a block of code on WebStorm?

In WebStorm, you can comment and uncomment blocks of code with Cmd+Shift+/ on macOS and Ctrl+Shift+/ on Windows/Linux.

Does WebStorm support react?

WebStorm provides code completion for React APIs and JSX in JavaScript code. Code completion works for React methods, React-specific attributes, HTML tags and component names, React events, component properties, and so on.


2 Answers

No. Please vote for WEB-16439 - a request for JSX comments support

like image 71
lena Avatar answered Sep 29 '22 13:09

lena


There's a pretty convenient/hacky way to do that - add a live template to your Javascript group in Editor -> Live templates with content like this:

{/*$SELECTION$*/}

then, in your code, select any react code, press ⌥⌘T and type the first letter of your template's abbreviation.

like image 36
bonbonez Avatar answered Sep 29 '22 14:09

bonbonez