2

I have been using VS2015 for about a year but I have had to reinstall it recently and I can't find the option to automatically add spaces to a expression as soon as a semicolon is entered. I have use it before but just can't find it now.

Example:

before semicolon: A=a+b+myFunction(a,b)

after semicolon: A = a + b + myFunction(a, b);

ildjarn
  • 62,044
  • 9
  • 127
  • 211
Jacko
  • 88
  • 12
  • not an exact duplicate, but [this](http://stackoverflow.com/questions/5755942/how-do-you-auto-format-code-in-visual-studio) may help. – jaggedSpire Jun 28 '16 at 16:23
  • The body of your question seems very different from your title. The title suggests you want to add a space at the end of the expression, before the semicolon, whereas the body of your question suggests you want typing a semicolon to trigger automatic formatting. – Cody Gray - on strike Jun 28 '16 at 17:01
  • Not exactly but its also very interesting @jaggedSpire – Jacko Jun 28 '16 at 17:02

1 Answers1

3

Under TOOLS->Options->C/C++->Formatting, you'll want to have "Automatically format statement when I type a ;" checked.

enter image description here

Ionian316
  • 2,303
  • 2
  • 28
  • 36
  • 1
    There is a C++14 tag in the question, but I can confirm the option is there under C/C++ too – KABoissonneault Jun 28 '16 at 16:52
  • @KABoissonneault Thanks. Missed the tag. Updated for C/C++. – Ionian316 Jun 28 '16 at 16:56
  • @Ionian316 I tried it but its not working even if clicking the *Automatically format statement when I type a ;*. Is it possible that another option overrides it? – Jacko Jun 28 '16 at 17:06
  • @Jacko Check your settings under _C/C++->Formatting->Spacing_. Make sure none of them are set incorrectly, especially in the **Spacing for operators** section. Also, do you have any third-party plugins or tools installed? – Ionian316 Jun 28 '16 at 17:39
  • I reset the settings, close and open Visual Studio 2015 and applied @Ionian316 answer and it worked! Thanks for your help and time. – Jacko Jul 04 '16 at 12:03