Replace quotes around JavaScript object properties
When pasting JSON with a lot of properties in a JavaScript file, I want to remove the double quotes around property names efficiently. How can I do it using WebStorm without deleting all quotes manually?
E.g.
{
"year": 2018,
"month": 9,
"day": 24,
"startHours": 6,
"startMinutes": 0,
}
should become
{
year: 2018,
month: 9,
day: 24,
startHours: 6,
startMinutes: 0,
}
Please sign in to leave a comment.
Replace (Ctrl+R) with regexp should help:
"([^"]+)":
$1:
Thanks, this did the trick.
You can click inside the object and then click `cmd+.` (on mac) to "Show context actions"
And then select option "Unquote property names"
While this is handy it would be a perfect fit to be also configurable in Editor -> Code Style -> <Language> -> Punctuation
That way it could easily applied to multiple files or automatically applied when reformatting code.