12

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

3
  • 3
    See stackoverflow.com/questions/39522593/… Commented Aug 8, 2019 at 3:18
  • @SergeyVlasov, your extension is brilliant! I wasn't able to find the answer by Googling or searching an StackOverflow. Happy to mark it as answer if you add your answer here. It may help someone else find it too. Thanks! Commented Aug 8, 2019 at 18:32
  • I hope the comment link will be enough to direct someone else to the existing answer. Commented Aug 9, 2019 at 3:38

4 Answers 4

12
  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

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

1 Comment

Can you tell me 1. whether this function only works for c sharp 2. which part of the plugin you mentioned this feature belongs to? As I am using visual studio 2022,I need to check if the feature it existed in 2017 has been removed in 2022. devblogs.microsoft.com/visualstudio/…
6

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.

1 Comment

It looks like it only works for c sharp github.com/dotnet/roslyn/issues/37874
3

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

1 Comment

Please add some explanation and link to official documentation to your answer such that others can learn from it (stackoverflow.com/help/how-to-answer)
0

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

3 Comments

I did see the settings inside VSCode, enabled them putting "insert", and it still does nothing... would you know why?
I'm sorry, I am describing Visual Studio, not VS Code.
Actually Inside Visual Studio, when using C#, Although in my settings I checked "insert semi-colons at statement ends" it does not apply. How come?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.