Vim calls Python to format JSON data

Source: Internet
Author: User
Vim calls Python format JSON data November,gnu/linuxpython3, vimopenwares

Python has a standard module called JSON, for encoding/decoding, serializing/serializing JSON format data.

The JSON data returned by the server is unformatted, the program uses no problem, if need to read Alexander.

You can use VIM to invoke the command-line tool provided by the Python JSON module json/tool.py format the JSON text.

Vim opens JSON data in command line mode

:%!python3-m Json.tool

% for all line ranges, use! Calling external commands

The-m option for Python3 specifies the name of the module and runs the corresponding. py file as a script. The script that runs here is json/tool.py

json/tool.py is a command-line tool that uses JSON modules to validate and format JSON data.

JSON is a python3 built-in module that is available in package libpython3.3-stdlib.

You can add shortcut keys in ~/.VIMRC

Map <F4> <esc>:%!python-m json.tool<cr>

Vim calls Python to format JSON data

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.