GitHub - bcicen/vim-jfmt: Automatically pretty-print and indent JSON files
source link: https://github.com/bcicen/vim-jfmt
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
vim-jfmt
jfmt
is a simple plugin for vim to automatically validate and format/pretty-print JSON files.
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
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK