0

I write C# files in VS2022.

Oftentimes I will write multi-line strings like so, and Intellisense will repeatedly (it takes < 40 characters) suggest to put it all on the same line, like so:

enter image description here

enter image description here

This is obviously awful, I don't want that, and I'm certainly not in the habit of writing multi-paragraph strings in one line, but it just keeps suggesting it. This would be fine... if a space didn't accept its suggestion, making it virtually impossible to write multi-line strings without turning C# suggestions off entirely.

Is there a way to turn off specifically IntelliCode suggestions to put multi-line strings on the same line? I see no such thing in the place I'd expect to find such an option should it exist:

enter image description here

4
  • Why do you not just write your multiline strings using "raw string literals"??? Commented Jan 6, 2024 at 20:33
  • Is there a way to do that without breaking indentation ? Commented Jan 6, 2024 at 20:35
  • like this? dotnetfiddle.net/7NHbcn Commented Jan 6, 2024 at 20:42
  • Yes there is, see the link in my answer to "raw string literals" Commented Jan 6, 2024 at 20:42

1 Answer 1

1

As you can see, the "[i]ntellicode suggestion is based on recent edits". This means, that it is based on edits you have made, and therefore does not map to any style rule. It proposes this, because you appear to have made similiar edits in the past. However there should be a light bulb, when hovering over this section, on which you can select ignore with a right click. See https://devblogs.microsoft.com/visualstudio/making-repeated-edits-easier-with-intellicode-suggestions/.

However I would recommend to use "raw string literals" either way. This is of course up to you though..

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. Despite many years of programming I was still convinced raw string literals involved writing lines past the first with no indentation somehow...
Turns out this project is in C#10, so raw string literals aren't available yet...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.