Ⅰ. 插件描述
a javascript source code formatterⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'xer0x/jsbeautify-come-back-be-here'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'xer0x/jsbeautify-come-back-be-here'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'xer0x/jsbeautify-come-back-be-here'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/xer0x/jsbeautify
Ⅳ. 文档说明
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 = 1to your .vimrc to usefunction ()instead offunction() - 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.