0

VS 2022 has a new "feature": when I hit enter in a quoted string literal, it splits the string so that there's a new partial string, + outside the string, a newline, and the rest of the string on the next line.

... that is, hitting enter while the cursor is between the 'u' and first 'f' turns

var foo = "stuff";

into

var foo = "stu" +
"ff";

How do I disable this "feature" (specifically for C#, but applying to all languages would be preferable)?

Specifically: when I hit enter, I want a plain ol' newline. If that makes the code invalid, so be it: I can decide whether to remove the newline, use string concatenation, use a multi-line string literal, or whatever else may be needed to fix the code.

4
  • What would you want to have VS do instead? I find the feature quite useful if you have long string constants (such as detailed error messages). Commented Feb 11, 2022 at 18:41
  • @PMF: I want it to insert a newline, even if that means that the code is illegal. Commented Feb 11, 2022 at 18:56
  • @minnmass Are you looking for "Tools" menu -> "Options" -> "Text Editor" -> "C#" -> "Advanced" -> Under "Editor Help", "Split string literals on enter"? Commented Feb 11, 2022 at 19:09
  • @AndrewMorton: yes, that's exactly it! Or, at least, it does the thing. It was enabled in my instance of 2019, but apparently didn't "take", so it never did anything. Commented Feb 11, 2022 at 19:10

0

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.