0.2.3 • Published 8 years ago
vimdiffpatch v0.2.3
vimdiffpatch
Create a Vim patch between two buffers.
Install
npm i vimdiffpatch
Example
const vimdiffpatch = require('vimdiffpatch')
const original = [
'// funny comment',
'const one = 1'
]
const modified = [
'let one = 1',
'let two = 2'
]
const patch = vimdiffpatch(original, modified)
Will output a patch that looks like:
[
{ line: 1, op: 'delete', val: [ '// funny comment' ] },
{ line: 1, op: 'replace', val: [ 'let one = 1' ] },
{ line: 1, op: 'append', val: [ 'let two = 2' ] },
]
This can be translated to Vim actions to patch the buffer
- delete -
exec '1d'
- replace -
call setline(1, 'let one = 1')
- append -
call append(1, 'let two = 2')
Is this a good idea?
Maybe