0.2.3 • Published 8 years ago

vimdiffpatch v0.2.3

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

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

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago