1
0
Fork 0
mirror of synced 2024-11-22 16:55:34 -05:00

add functions/PrettifyJSON.vim

This commit is contained in:
Huaishun Hu 2017-12-18 17:18:31 +08:00
parent 29bab2d6c3
commit ae11bf7ce6
2 changed files with 17 additions and 0 deletions

12
functions/PrettifyJSON.js Normal file
View file

@ -0,0 +1,12 @@
const fs = require('fs')
function prettifyJSON(filePath) {
fs.readFile(filePath, (err, data) => {
console.log(JSON.stringify(JSON.parse(data), null, 4));
});
};
const argFilePath = process.argv[2];
prettifyJSON(argFilePath)

View file

@ -0,0 +1,5 @@
function! PrettifyJSON()
execute ':r !node ~/.vim_runtime/functions/PrettifyJSON.js %'
endfunction