Ⅰ. 插件描述
Code beautifier for vim.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'zeekay/vim-beautify'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'zeekay/vim-beautify'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'zeekay/vim-beautify'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/zeekay/vim-beautify
Ⅳ. 文档说明
# vim-beautify
Why live with ugly code? Adds filetype specific :Beautify command which
beautifies buffers or ranges.
Built-in support
C, C++
- astyle
CSS
- css-beautify
HTML, XML
- html-beautify (default)
- tidy
Java
- astyle
JavaScript
- js-beautify
JSON
- js-beautify
- json.tool
- node (default)
- uglifyjs
Go
- gofmt
Python
- autopep8 (default)
- docformatter (default)
Usage
You can beautify a buffer or range using :Beautify. The appropriate beautifier
(or beautifiers) will be run according to detected filetype.
An optional filetype or beautifier name may also be specified to trigger a
specific beautifier regardless of detected filetype. For instance, to beautify a
block of JSON inside of a Markdown file you can simply select a range and call:Beautify json.
API
You can customize the existing beautifiers, arguments used or define new
beautifiers:
let g:beautify = {
\ "beautifiers": {
\ "python": ["autopep8", "docformatter"],
\ },
\ "definitions": {
\ "autopep8": {
\ "args": "--aggressive",
\ }
\ }
\ }