All Questions
Tagged with code-formatting visual-studio
121
questions
0
votes
1
answer
30
views
Visual Studio 2022 - indent closing function paren with beginning of argument
In Microsoft driver code (even the driver templates included in VS), they frequently format the function signature like this:
VOID
EvtIoStop(
_In_ WDFQUEUE Queue,
_In_ WDFREQUEST Request,
...
0
votes
1
answer
154
views
Visual Studio Code Cleanup: How to avoid removing unassgiend/unused variable when file is on save
I am using Code Cleanup in Visual Studio and noticed when file is on save.
The unused variable will be removed like:
I tried editing the .editorConfig file but it didn't seem to work with any of the ...
4
votes
2
answers
190
views
How do you set formatting rules for C# spread operator in Visual Studio?
I know this is probably not the right place to ask this, but I doubt I'd find an answer somewhere else.
Visual Studio 17.9.5 will, by default, format the following snippet as such
int[] arr = [1, 2];
...
0
votes
0
answers
66
views
Ctrl k+D not working on last microsft vs update
After last update of Microsoft VS ctrl K+D for format code not working for razor page although it format cs page
I tried to format form Edit-Advanced-format document but the code didn't format
Then i ...
0
votes
1
answer
457
views
Visual Studio: how to format each input parameter in a line in function declaration and function definition?
I have a function like this void my func(int a, int b, int c);
Is there any tool, any way or any VS extension to format (convert) my function as
void myfunc(
int a,
int b,
int c);
void ...
5
votes
0
answers
366
views
How to format C++ code in Visual Studio using my own rules?
I am using Visual Studio 2019.
I want to create a setting file for Visual Studio which consists of my own formatting rules and anyone can import those settings for their Visual Studio. (I think this ...
1
vote
0
answers
147
views
Require 'this' keyword in VS2022 while formatting and compiling
I upgraded to Visual Studio 2022 (17.4.4) and see that the formatting options have changed significantly.
I have tried experimenting and searching but cannot figure out how to force the required use ...
0
votes
1
answer
911
views
How to change tab size in Visual Studio 2022 for Mac?
I am using Visual Studio 2022 for Mac (currently v17.4). I want to change tab size as they are too big. I cannot see such option anywhere and even in the documentation it says it doesn't apply to ...
0
votes
2
answers
430
views
Visual Studio Community C# code formatting
I am trying to format C# code of a WinForms .NET Core 7.0 project in Visual Studio Community:
private void Form1_Load(object sender, EventArgs e)
{
Dictionary<String, String> Dictionary = ...
0
votes
1
answer
86
views
Visual Studio 2019 - Multiple format settings
The code base I am working with uses a KNR formatting like this.
void foo(bool bar) {
if (bar) {
// do something
} else {
// do something else
}
}
I am generally not a fan ...
4
votes
1
answer
3k
views
How to change default parentheses formatting in Visual Studio
Hi guys I'm new to C# and VisualStudio and I want to change the default formatting style from this:
void Start()
{
}
To this:
void Start() {
}
Is it possible? Anyone know how to ...
38
votes
5
answers
46k
views
'Format code' and 'sort using' on save in Visual Studio 2022
I and my team spent the last few months defining rules about C# code formatting and style for our project, so we ended up with an .editorconfig file.
Moreover, we all installed the extension ...
2
votes
1
answer
173
views
Format (4 spaces) all code files in Visual Studio?
I was working on an old branch feature/old-request, that branch did not have the .editorconfig file that informs Visual Studio to use 4 spaces (company agreed formatting).
So on my old branch, Visual ...
2
votes
1
answer
2k
views
How to disable adding automatically spaces (e.g.in the if condition line) in VS17
I'm using VS17 and I would like to change my coding settings so that VS stops adding spaces at e.g. if conditions in language C. I searched for enabling this option but unfortunaly I could find a ...
0
votes
1
answer
637
views
Is there a difference between 'type const &value' and 'type const& value'?
The topic basically says it all. I'm following a tutorial where it says type const &value, but visual studio keeps automatically correcting it to type const& value.
Is there a difference?
Is ...