Ⅰ. 插件描述
format json lineⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin '/vim-json-line-format-may-fear-less'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle '/vim-json-line-format-may-fear-less'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug '/vim-json-line-format-may-fear-less'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/vim-scripts/vim-json-line-format
Ⅳ. 文档说明
格式化json文本行(format json text line)
_ _ _ _ _ _ ____ __ __ _
| / __| / | | | | | |_ | | | ____| | ___/ | _ | / | / |_ _|
| __ | | | | | |___| | | || | | _| __| | | | | | |_) | |/| | / _ | |
| |_| |___) | |_| | | |___| |___ | || | | |__|___| _|| |_| | _ <| | | |/ _ | |
___/|____/ ___/|_| _| |_____|___|_| _|_____| |_| ___/|_| __| |_/_/ __|
if你用vim打开某文本内容为每行一个json的文本文件,内容如下:
If you open a text by VIM which contents are json lines text, such as:
{"question": "u53d1u5458u5de5u7684u4e1cu897f", "choices": ["u6781u6b63", "u504fu6b63", "u4e2du6027", "u504fu8d1f", "u6781u8d1f", "u975eu8bc4u4ef7"]}
{"question": "u6613u8fc5u8fd9u6837u6ca1u6cd5u6bd4", "choices": ["u6781u6b63", "u504fu6b63", "u4e2du6027", "u504fu8d1f", "u6781u8d1f", "u975eu8bc4u4ef7"]}
{"question": "u5f88u591au4e1cu897fu5df2u7ecfu6bd4", "choices": ["u6781u6b63", "u504fu6b63", "u4e2du6027", "u504fu8d1f", "u6781u8d1f", "u975eu8bc4u4ef7"]}
由于编码和没有换行的问题不便于查看,或许说根本他妈的就没法看!那么!请立刻检查系好您的安全带,因为这个插件可以让你fly!
These json lines are inconvenient for human to read it, because of formating and encoding. Using this plugin, you can these lines easily!

安装(Install)
- 可以直接将
plugin/json_line_format.vim复制到你的.vim/plugin下就ok
(First Way: Copyplugin/json_line_format.vimto your.vim/plugin) - 如果是使用Vundle,那么在你的
.vimrc中的plugin管理中添加
Plugin 'axiaoxin/vim-json-line-format'
然后在VIM中:PluginInstall你懂的哟
(Second way: if you use Vundle, add Plugin 'axiaoxin/vim-json-line-format' in your .vimrc, then use :PluginInstall to install this plugin)
用法(Usage)
打开文件,以normal方式在需要查看的行上按<leader>jp快捷键即可在底部打印它格式化后的样子,使用<leader>jw快捷键直接将其修改为格式化后的json
Open a file in Normal mode, move your cursor on the json line, use <leader>jp to show formated json by print it, use <leader>jw could change the text to formatted json.
非正确json格式无法格式化
error json can not format!