I can\'t seem to get inline Javascript indenting properly in Vim. Consider the following:
$(document).ready(function() {
// Closing brace correctly inde
The most comprehensive and bug-free Javascript indentation script is the one by Preston Koprivica. The so called OOP script that is in the proposed answer has severe bugs, and does not indent code properly that has square brackets.
Most of these answers are from 2009 and, frankly, are out of date.
vim-javascript is much more recent and up-to-date than Preston's script.
Installation is a bit more complicated if you haven't started using Vundle yet, but it doesn't seem to suffer from the issues of the alternatives.
I had this same issue. This is the best of all Javascript indentation scripts:
http://www.vim.org/scripts/script.php?script_id=1840
It requires the IndentAnything plugin
http://www.vim.org/scripts/script.php?script_id=1839
As an added bonus, I wrote this indent script that will make Javascript blocks quite pretty. It uses the default html indenter by default (and the IndentAnything one when within a Javascript block)
http://gist.github.com/371902