How can I setup webstorm to automatically add semi-colons to javascript functions, methods, etc

There is no way to insert it automatically, you need to use the Complete Statement action (Ctrl+Shift+Enter).

You also need to check that Use semicolon to terminate statements option is enabled in Settings | Code Style | JavaScript | Other tab.


You can make a macro and keyboard shortcut:

Record Auto semicolon macro and bind shortcut to it:
1. Edit -> Macros -> Start Macro Recording
2. In the editor go to the end of line by pressing End
3. put semicolon ';'
4. Edit -> Macros -> Stop Macro Recording
5. Give a name, for example 'Auto semicolon'
6. Open settings (Ctrl + Alt + s), select Keymap
7. Expand Macros node
8. Select 'Auto semicolon', in the context menu choose Add Keyboard Shortcut
9. Set Ctrl + ; as First keystroke
10. Save/Apply settings
11. Enjoy!
12. Try it out, in the middle of code line, hit Ctrl + ;
 
// some useful combinations:
Ctrl + ,    put colon at the end of line
Ctrl + ;    put semicolon at the end of line
Ctrl + .    put => at the end of line

From https://gist.github.com/umidjons/9383758

Would be a lot cooler if there was an option to do it automatically though...


For IntelliJ Idea 2018, follow the steps below:

  • Open Settings: Ctrl+Alt+S
  • Editor>Code Style>JavaScript
  • Select Tab > Punctuation
  • In dropdown, select "Use/Use always" semicolon to terminate statements
  • Apply and OK

This will add extra semicolon in JS.