+ 4

Shortcut key to get semicolon(;) at the end of a line.

Does anyone know how to automatically append a semicolon-';' at the end of a statement in JS or other related programming languages, even when your cursor is somewhere in between the line? I've seen instructors in tutorials and such do this and have always wondered how exactly it's being done. I tried looking it up but it's mostly suggesting plugins and stuff in the editor that's being used. Any heads-up on this would be much appreciated.

5th Mar 2024, 3:32 PM
Tharun Chandramohan
Tharun Chandramohan - avatar
5 Respostas
+ 2
There could be many different approaches but all of them depend on your editor / IDE. This one list many solutions for VS Code: https://stackoverflow.com/questions/30118344/how-to-add-semicolon-to-the-end-of-the-line-in-visual-studio-code - key bindings / macros - plugins - configuration - autoformatter The easiest manual way is press End key to jump to the end of line, then press ; key :)
6th Mar 2024, 4:29 AM
Tibor Santa
Tibor Santa - avatar
+ 3
I don't think there would be any shortcut because it will add after every line even after any condition like if else block or any other line where should not be semicolon (;). In this case you will have to remove manually after those blocks. Some languages don't use semicolon even in JS also it is not necessary but some language strictly follow this like Java, C, C++.
5th Mar 2024, 3:54 PM
A͢J
A͢J - avatar
+ 2
A͢J so it depends on the editor also that we use?
5th Mar 2024, 4:23 PM
Tharun Chandramohan
Tharun Chandramohan - avatar
+ 2
Tibor Santa Thanks, I guess this is the most viable option. 👍
6th Mar 2024, 4:48 AM
Tharun Chandramohan
Tharun Chandramohan - avatar
+ 1
Python program
6th Mar 2024, 8:25 AM
Pankaj Patel
Pankaj Patel - avatar