8

Whenever I use the auto-format shortcut (Shift + Alt + k) in Visual Studio Code inside a file that contains this piece of code -

var keyframes = [
  {opacity: 0, transform: 'translate(0, 4em)'},
  {opacity: 1, transform: 'translate(0)'}
];

I get this -

var keyframes = [
  { opacity: 0, transform: 'translate(0, 4em)' },
  { opacity: 1, transform: 'translate(0)' }
];

I wonder if there's any way to tell the auto-format not to insert all the spaces?

Justin XL
  • 38,763
  • 7
  • 88
  • 133

2 Answers2

6

Sorry, but the formatting options are currently not exposed to the user. It is high on our backlog.

Erich Gamma
  • 331
  • 1
  • 3
  • Thanks Erich, if you could update the answer once it's supported, I will gladly accept it. – Justin XL Feb 23 '16 at 23:15
  • @JustinXL it seems to me the OP should accept the best correct answer -assuming there is a correct answer posted to the question. Liking the correct answer shouldn't be a requirement. ;-) – Karl Feb 26 '16 at 19:37
  • Do we have this option now? (I want to use it on React) – BrunoLM Mar 28 '17 at 23:04
  • I was just wondering if this (https://github.com/Microsoft/vscode/issues/3039) is the correct ticket to observe the progress on the issue or if I would have to add a different one – siyb Apr 24 '17 at 15:36
  • 1
    There is now. Go through the answers – iam.Carrot Jul 14 '17 at 07:25
5

If anyone is looking for that option in react it is:

"typescript.format.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces": true

Then it will format this

<option key={org.id} value={org.id}>{org.displayName}</option>

like this:

<option key={ org.id } value={ org.id }>{ org.displayName }</option>
BrunoLM
  • 97,872
  • 84
  • 296
  • 452
  • that's correct. I've got the same thing. really painful as the rest of the team is using intelliJ – Bo Chen Nov 15 '17 at 03:46