-
August 21st, 2021, 03:17 AM
#1
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
-
August 21st, 2021, 03:28 AM
#2
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++23 Compiler: Microsoft VS2022 (17.6.5)
-
August 29th, 2021, 01:58 AM
#3
Re: Stopping unnecessary style corrections
Originally Posted by John E
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/
-
September 2nd, 2021, 08:08 AM
#4
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
-
September 2nd, 2021, 09:53 AM
#5
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++23 Compiler: Microsoft VS2022 (17.6.5)
-
September 2nd, 2021, 10:50 AM
#6
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
-
September 2nd, 2021, 11:04 AM
#7
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++23 Compiler: Microsoft VS2022 (17.6.5)
-
September 3rd, 2021, 05:37 AM
#8
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
-
September 3rd, 2021, 06:50 AM
#9
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++23 Compiler: Microsoft VS2022 (17.6.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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|