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
Settings -> in Search bar type: 'semicolon' -> change values to 'insert' for both JS and TS, save and close. Now every time on save, VSCode will look for missing semicolons inside the file you're in and append them.
The trailing semicolon is the last semicolon in a declaration block and it is optional. This rule ignores: Less mixins. trailing // comments.
Alt + Enter Insert semicolon at the end of line and continue on the new line Ctrl + Alt + Enter Insert semicolon and stay at the same position Show activity on this post. Visual Studio Code doesn't appear to directly support adding a semi-colon to the end of a line via a keyboard shortcut, meaning it'll need a custom extension to support it.
When the extension moves the semi-colon to the end of the line it also moves your cursor to the next line, thereby making your typing very fluid without having to manually put semi-colons explictly at the end of each line or even having to hit the enter key to move to the next line.
To install this extension: 1 Launch Visual Studio Code 2 Press "Ctrl+P" (or "Command+P" on the Mac) 3 type "ext install Trailing Semicolon" to search for the extension 4 With the extension visible below the search box, click the Install Extension icon in the bottom right of the extension. (It's a cloud with an arrow pointing down...)
No need to close the bracket or type the semicolon. It's supposed to place a semicolon even when your cursor is no at the end, to save the trouble of pressing End. It's just a minor convenience thing, I'm just spoiled
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.
Simply I used prettier code formatter and it fixed all my problems.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With