Beautify your javascript,html,css source code inside Vim
JavaScript VimL
Latest commit 1305dd9 Jun 18, 2014 @michalliu fix css media query
Failed to load latest commit information.
plugin/sourcebeautify fix css media query Jun 18, 2014
tests add more tests Jun 16, 2014
.gitignore update git ignore May 17, 2012 Update Jun 16, 2014


Beautify your source code in Vim.

Language support:

More language support is well welcomed, your can develop it by pure javascript, see Customization section for more info.


First, Install dependencies:

  1. jsruntime.vim
  2. jsoncodecs.vim

Then, Copy plugin/sourcebeautify to vimfiles/plugin


Sourcebeautify is a filetype plugin. By default VIM can't detect json filetype automaticly. You can either add following code to your vimrc to solve the problem or install json.vim

au BufRead,BufNewFile *.json setf json



Your <Leader> key is often \


  1. jsbeautify options

    Take a look at, this file contains following code


    %s refers to the codes before beautify, the other part is pure javascript, for example


    javascript beautifier options, html beautifier options, css beautifier options, jsonlint options

  2. add more language support

    If you wants this plugin to support cpp file, you should create beautify-cpp.js and

    These two files should be written by pure javascript, then modify sourcebeautify.vim add declaration and alias

    " sourcetype that support by this plugin
    let s:beautifiers.supportedSourceType={
    " sourcetype name alias
    let s:beautifiers.supportedSourceTypeAlias={


  1. Einar Lielmanis - author of js-beautify provides beautifier of javascript,html,css file
  2. Zach Carter - author of jsonlint provides error checker and beautifier of JSON file
  3. Vadim Kiryukhin - author of vkBeautify provides XML and SQL beautifier