mirror of
1
0
Fork 0

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