Sandra
Sandra

Reputation: 708

How to automatically add semicolon to end of line in Visual Studio 2019

My question is similar to How to add semicolon to the end of the line in visual studio code, but for Visual Studio 2019. The extensions mentioned in the answers, and others I've been able to find, only work in VS Code or earlier versions of VS it seems.

As @gavin so eloquently put it in that question:

... in vs code, when you write a method call, it automatically closes the open parameter for you and your cursor ended up before the ). Now if you want to write a new statement, you literally have to take your right hand off the jkl; position and click on the end or the right arrow key and then take your right hand back to the jkl; position to type the semicolon. I use shift + enter and it saves me around half a second for each statement to reposition my right hand

Upvotes: 12

Views: 21863

Answers (4)

Tom Chadaravicius
Tom Chadaravicius

Reputation: 393

Adding semicolon can be done by "Edit"->"Advanced"->"Format Document". But first, configure JavaScript->Text Editor->Formatting->General to "Insert semicolons at statement ends" (I insert a screenshot below). Text Editor->Formatting->General

Upvotes: 0

ismadev
ismadev

Reputation: 93

Simply I used prettier code formatter and it fixed all my problems.

Upvotes: 3

Maicon Heck
Maicon Heck

Reputation: 2377

  1. Install Productivity Power Tools 2017/2019 (if it is not already installed)
  2. Press Shift+Enter to add ";" automatically at end of the line:

enter image description here

Upvotes: 12

Abdurrahman
Abdurrahman

Reputation: 181

I noticed that in the latest version of VS2019, if you are within parentheses and you type a semicolon (without any special shortcuts), it automatically moves it for you towards the end of the brackets where it should be. I don't have any special extensions installed for that.

It doesn't work for every situation. It seems that you need to be within brackets.

Upvotes: 6

Related Questions