a javascript source code formatter
Vim script
Switch branches/tags
Nothing to show
Pull request Compare This branch is 17 commits ahead of vim-scripts:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
ftplugin/javascript
README.md

README.md

jsbeautify.vim

A plugin to format your javascript souce code. It can be helpful when reformatting JSON snippets and compressed javascript.

This fork of vim-scripts/jsbeautify has a couple small changes to pass JSLint. For a handy JSLint vim-plugin checkout jslint.vim.

The original JS version can be found at: jsbeautifier.org
Plus a Node.JS version is here: js-beautify-node

usage:

  • <leader>ff
    or
  • bind the g:Jsbeautify() function to any short key you like.

changes:

  • It is filetype plugin so it only loads for javascript files. This might not be ideal if you want to reformat .json files or use the javascript.jquery filetype.
  • If you use JSLint's strict whitespace rules, then add let g:Jsbeautify_jslint_whitespace = 1 to your .vimrc to use function () instead of function()
  • To expand tabs into spaces use let g:Jsbeautify_jslint_expandtab = 1. Thanks to somethingkindawierd for this.

Thanks to aj3423 fork creating the vimscript version of this brilliant reformatter.