CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,780

    Stopping unnecessary style corrections

    A project I'm involved in has a style of inserting spaces for better visibility - like this:-

    Code:
    int SomeFunc ( int whatever );
    but if I make any change to an existing line, VS2019 has an annoying habit of correcting to what it thinks is the 'proper' style - i.e.

    Code:
    int SomeFunc(int whatever);
    Is there a setting somewhere that'll turn this off?
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  2. #2
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,553

    Re: Stopping unnecessary style corrections

    Try looking at these VS configuration options:

    Tools/Options/Text Editor/c c++/Code Style/Formatting/Spacing/spacing for function parameters
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++20 Compiler: Microsoft VS2019 (16.11.5)

  3. #3
    Join Date
    Feb 2017
    Posts
    621

    Re: Stopping unnecessary style corrections

    Quote Originally Posted by John E View Post
    VS2019 has an annoying habit of correcting to what it thinks is the 'proper' style
    Generally, I find VS 2019 a little too complex and invasive for my taste so I've contemplated switching to VS Code for quite some time.

    But now I see VS 2022 is on the brink of being released and I wouldn't want to miss that! There's a preview available already,

    https://devblogs.microsoft.com/visua...now-available/

  4. #4
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,780

    Re: Stopping unnecessary style corrections

    Thanks 2kaud - I just seem to have 1 weird style thing renaming which I can't seem to track down - i.e. it's removing spaces if they're preceded by a comma. So something like this:-

    Code:
    void Hello (int i, bool b, unsigned u);
    will keep getting converted to this:-

    Code:
    void Hello (int i,bool b,unsigned u);
    Any idea what I'd need to change in order to disable that?
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  5. #5
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,553

    Re: Stopping unnecessary style corrections

    Tools/Options/Text Editor/c c++/Code Style/Formatting/Spacing/spacing for delimiters

    Same config page as before - just further down. Has options for space before/after coma etc.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++20 Compiler: Microsoft VS2019 (16.11.5)

  6. #6
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,780

    Re: Stopping unnecessary style corrections

    Thanks 2kaud - interestingly, my options were all disabled here. So I've just toggled them on and then off again.
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  7. #7
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,553

    Re: Stopping unnecessary style corrections

    You need the option 'insert space after comma' set. If that was disabled, that's why you had no space!
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++20 Compiler: Microsoft VS2019 (16.11.5)

  8. #8
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,780

    Re: Stopping unnecessary style corrections

    Thanks 2kaud. I corrected that and I also discovered another setting at Tools/Options/Text Editor/C C++/Code Style/Formatting/When I paste. It was initially set to Indent and format

    But when I'm editing someone else’s code I tend to copy & paste it first (so that I can easily get back to the original code if I screw something up...) So it’s probably the copy & paste operation that’s been introducing a lot of the formatting problems here.
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  9. #9
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,553

    Re: Stopping unnecessary style corrections

    The code style formatting gives you enough options to hang yourself!
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++20 Compiler: Microsoft VS2019 (16.11.5)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured