How do I fix incorrect inline Javascript indentation in Vim? How do I fix incorrect inline Javascript indentation in Vim? javascript javascript

How do I fix incorrect inline Javascript indentation in Vim?


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.


Use JavaScript Indent: Javascript indenter (HTML indent is included) by Preston Koprivica. Thanks for the heads-up from oligofren - give him an up-vote.


The scripts mentioned above do not format the closure-syntax often used in jQuery correctly:

$(function() {  // only one level of indentation, not two});

This script works better for me: http://www.vim.org/scripts/script.php?script_id=2765