Justin Moore
Justin Moore

Reputation: 86

How to disable automatically adding semicolons to end of lines in Visual Studio 2019

Note: Everyone trying to say this is not default behavior for Visual Studio and must be an addon/extension/setting... please validate that assumption before stating it as fact. I've done the testing. It's default behavior. Install Visual Studio on a new machine with factory default settings and this behavior is present. No extensions, addons, or anything. It was added in version 16.1, as it does not happen prior to that version of Visual Studio. I cannot identify the actual name of this feature or how to disable it.


I'm trying to figure out how to disable the feature described in this Developer Community post.

This is not behavior added by an addon or extension. It is present in a fresh install of VS 2019.

Upvotes: 1

Views: 1319

Answers (2)

David Mårtensson
David Mårtensson

Reputation: 7600

There now is a setting under Text Editor->C#->Intellisense "Automatically complete statement on semicolon" that is responsible for this mad man behavior.

Why this was implemented for C# where a misplaced semicolon almost never can cause runtime errors since the compiler will catch it I fail to understand despite reading through all the comments on GitHUb with users complaining of the feature and microsoft defending it.

If anyone actually have had this help them ever, please explain in what case :D

Upvotes: 0

Jawad
Jawad

Reputation: 11364

Only place I was able to find where you can change the semicolon preference was under Tools > options > Text Editor > JavaScript/TypeScript > Formatting > General

Last section of the General has Semicolon Preference where you can "Insert Semicolons at statement ends. If you have a check there, remove it.

The links you have posted in your question talks about, 'semicolon automatically moving to the end of the statement', rather than Visual Studio adding a semi-colon at the end of the statement.

This is explained in your other Developer post: The semicolon is being moved by the Complete Statement feature. Since the semicolon was typed inside an argument list where a semicolon is not valid, the feature assumes you want to complete the collection initializer statement by putting a semicolon at the end

I dont believe there is any way of turning that off. I can recommend using Visual Studio Code that allows behavior like adding semicolons without automatically moving it to the end.

Upvotes: 3

Related Questions