Search code examples
c#visual-studiocode-formatting

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];
int[] biggerArr = [0, .. arr];

but I would really like to have it not add the space between the spread operator and the variable name as such

int[] arr = [1, 2];
int[] biggerArr = [0, ..arr];

However, I don't seem to find any relevant setting for this under Tools > Options > Text Editor > C# > Code Style > Formatting > Spacing. Does anyone have any idea what setting controls this? Another interesting thing is that this is considered proper formatting by Visual Studio

int[] arr = [1, 2];
int[] biggerArr = [
    0, ..arr];

EDIT: Submitted a Developer Community request


Solution

  • Seems there isn't an option for this and there isn't a plan to implement this as discussed here.