vim增加格式化功能

使用python格式化json:

:%!python -m json.tool

只要安装了python就可以调用这个命令实现json的格式化

注意:当有汉字的时候会出现汉字编码问题,解决办法是修改tool.py, 在main中的json.dump添加一个参数ensure_ascii=False

使用jdaddy.vim格式化json:

安装:
使用vundle添加

Plugin 'https://github.com/tpope/vim-jdaddy.git'
  • aj provides a text object for the outermost JSON object, array, string, number, or keyword.
  • gqaj “pretty prints” (wraps/indents/sorts keys/otherwise cleans up) the JSON construct under the cursor.
  • gwaj takes the JSON object on the clipboard and extends it into the JSON object under the cursor.
    There are also ij variants that target innermost rather than outermost JSON construct.

格式化xml

:%!xmllint --format -

需要在操作系统中安装xmllint程序,保证命令行可以调用。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值