How can I format JS code in Vim?
VIM plugin Jsbeautify could handle jQuery correctly. It's the vim plugin version of the online Jsbeautify.
There is a far simpler solution that requires no vim plugins.
Install js-beautify to your system python:
pip install jsbeautifier
Then add this to your .vimrc:
autocmd FileType javascript setlocal equalprg=js-beautify\ --stdin
That's it.
Run :help equalprg
to see why this works.