tags:

views:

197

answers:

1

I recently asked a question about formatting JavaScript code in Vim. And I've also noticed this question, and did some Google searching. Nonetheless, my quest continues.

I've given up on a Vim plugin that will properly format contemporary JS code. But maybe there's a command line tool I could call from within Vim. Here are my desiderata:

  • Just one thing to install. Ideally just a script I can drop into my ~/bin dir. Doesn't require a supporting interpreter that I probably don't have on my OS X or Linux systems and that I would have to install just to use this one little tool.

  • Written in something commonplace like Perl, C, Ruby, the bash shell scripting language, or even Java.

  • I'm not super picky about exactly how it formats the code as long as it does something reasonable and doesn't choke on jQuery-style JavaScript.

+2  A: 

There's a tool written in perl that can do it: JavaScript::Beautifier

I would give GNU indent a go. It has a lot of options and if you use the right ones you might be able to get exactly what you want.

omouse