2

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.

Community
  • 1
  • 1
Ethan
  • 57,819
  • 63
  • 187
  • 237
  • This is not exactly what you want, but since javascript has a C-like syntax, you could use [indent][1] [1]:http://www.gnu.org/software/indent/ – Aif Oct 31 '09 at 18:35

1 Answers1

3

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.