Synchronize code snippet among files.
npm i -D sync-snippet
1.Use ////sync-code-snippet:ws:start
and ////sync-code-snippet:ws:end
to mark snippet area in files.
a.js:
////sync-code-snippet:ws:start
////sync-code-snippet:ws:end
b.js:
////sync-code-snippet:ws:start
var a=1;
////sync-code-snippet:ws:end
c.js:
////sync-code-snippet:ws:start
////sync-code-snippet:ws:end
const sync = require("sync-snippet")
sync({
name: "ws", //should be unique in this pc
regexp: /\/\/\/\/sync-code-snippet:(\w+):(\w+) */g, //should be like this: ////sync-code-snippet:ws:end
files: [
{
path: "/home/blackmiaool/a.js"
},
{
path: "/home/blackmiaool/b.js"
},
{
path: "/home/blackmiaool/c.js"
},
]
});
Yes. It get the indentation by calculating the spaces between the column0 and the start mark and synchronize the snippet area accordingly. Remember to make the snippet area and the start mark have the same indent.
Wrong:
////sync-code-snippet:ws:start
var a=1;
////sync-code-snippet:ws:end
Right:
////sync-code-snippet:ws:start
var a=1;
////sync-code-snippet:ws:end
Clone the repo, run the start.js and try to edit the files in ./test folder.