How do I fix incorrect inline Javascript indentation in Vim?
Posted
by Charles Roper
on Stack Overflow
See other posts from Stack Overflow
or by Charles Roper
Published on 2009-03-06T20:13:33Z
Indexed on
2010/04/20
1:43 UTC
Read the original article
Hit count: 477
JavaScript
|vim
I can't seem to get inline Javascript indenting properly in Vim. Consider the following:
$(document).ready(function() {
// Closing brace correctly indented
$("input").focus(function() {
$(this).closest("li").addClass("cur-focus");
}); // <-- I had to manually unindent this
// Closing brace incorrectly indented
$("input").blur(function() {
$(this).closest("li").removeClass("cur-focus");
}); // <-- This is what it does by default. Argh!
});
Vim seems to insist on automatically indenting the closing brace shown in the second case there. It does the same if I re-indent the whole file. How do I get it to automatically indent using the more standard JS indenting style seen in the first case?
© Stack Overflow or respective owner