0

I use VS Code for my C# code. Unfortunately, the formatter lets you define many details of your code, especially where spaces should go within a line, a function call, a conditional statement etc., and enforces the whole set of options.

This makes it impossible to intentionally add whitespace for visual orientation, such as :

        public int                Key    { get; set; } = 0;
        public string             Name   { get; set; } = string.Empty;
        public UnitId             Unit   { get; set; } = UnitId.None;
        public UnderlyingDataType Type   { get; set; } = UnderlyingDataType.UINT32;
        public string             Source { get; set; } = string.Empty;

as the formatter will shrink it back at next occasion:

        public int Key { get; set; } = 0;
        public string Name { get; set; } = string.Empty;
        public UnitId Unit { get; set; } = UnitId.None;
        public UnderlyingDataType Type { get; set; } = UnderlyingDataType.UINT32;
        public string Source { get; set; } = string.Empty;

I do wish to use some of the formatter settings, such as 4 spaces for a tab, auto-indentation etc, but would like to set my other whitespace deliberately.

In the settings (Omnisharp), it is only possible to say "true" or "false" to distinct space settings, but they cannot just disabled at all.

Can anyone help?

Alternatively, is it possible to switch off this formatter at all, and use something else to correct indentation (of a selection)? (Eclipse, for instance, has the shortcut Ctrl-i, which does only indentation, but no whitespace correction.)

Ingmar
  • 2,361
  • 3
  • 19
  • 33

0 Answers0