vim-jfmt


Ⅰ. 插件描述

Automatically pretty-print and indent JSON files

Ⅱ. 基本信息

创建日期:  2017-09-15
使用用户:  1
Github星:  11
插件作者:  bradley

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'bcicen/vim-jfmt'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'bcicen/vim-jfmt'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'bcicen/vim-jfmt'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/bcicen/vim-jfmt

Ⅳ. 文档说明

# vim-jfmt

jfmt is a simple plugin for vim to automatically validate and format/pretty-print JSON files.

<p align="center">vim-jfmt</p>

Installing

Ensure you have jq installed and available in your local $PATH

Then, add to your .vimrc using your plugin manager of choice; e.g. vundle:

Plugin 'bcicen/vim-jfmt'

Usage

By default, jfmt will only validate JSON files on save, opening a location list with any parse errors encountered.

To manually format/pretty-print the open file, use the :Jfmt command. To automatically run this on save as well, simply add the below to your .vimrc:

let g:jfmt_autofmt  = 1

Options

Additional options may be provided to jq by setting g:jfmt_jq_options:

" use tabs instead of spaces for indentation
let g:jfmt_jq_options = '--tab'

Likewise, the default filter(.) can be changed by setting g:jfmt_jq_filter

添加新评论