4

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 ?

Dimitri Kopriwa
  • 13,139
  • 27
  • 98
  • 204

2 Answers2

10

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.

Bas Leijdekkers
  • 23,709
  • 4
  • 70
  • 68
  • I did (Alt+Enter) after selecting the whole content of my file, and I do not have `Unquote property names` in my menu. I am using Idea Ultimate 2018 – Dimitri Kopriwa Feb 27 '19 at 15:26
0

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

kaybee99
  • 4,566
  • 2
  • 32
  • 42