Dimitri Kopriwa
Dimitri Kopriwa

Reputation: 14375

Intellij IDEA, code styling for javascript object, how to remove quotes when not necessary around key?

We would like to edit the javascript code styling in intellij to remove quotes around key within object when not necessary:

{
  "year": 2018,
  "month": 9,
  "day": 24,
  "startHours": 6,
  "startMinutes": 0,
}

should become

{
  year: 2018,
  month: 9,
  day: 24,
  startHours: 6,
  startMinutes: 0,
}

Using CTRL+SHIFT+F (Format code), is this possible ?

Upvotes: 4

Views: 1771

Answers (2)

kaybee99
kaybee99

Reputation: 4744

I've found a fairly efficient solution. It does require mouse clicks on every key though so may not be appropriate for large scale replacements:

Double click on the key to highlight. Then press Ctrl/Cmd+C+W+V

This copies the key, widens the selection to include the quotes and then pastes over the top

Upvotes: 0

Bas Leijdekkers
Bas Leijdekkers

Reputation: 26482

I don't think this is possible using Format code. What you can do is Select All (Ctrl/Cmd+A) and then invoke the intention (Alt+ Enter) Unquote property names.

Upvotes: 14

Related Questions