Skip to content

Instantly share code, notes, and snippets.

@bfredl
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bfredl/19c13ba8014bb761528c to your computer and use it in GitHub Desktop.
Save bfredl/19c13ba8014bb761528c to your computer and use it in GitHub Desktop.
import xerox
class NvimClipboard(object):
def __init__(self, vim):
self.provides = ['clipboard']
def clipboard_get(self, reg):
txt = xerox.paste()
# emulate vim behavior
if txt.endswith('\n'):
txt = txt[:-1]
regtype = 'V'
else:
regtype = 'v'
return txt.split('\n'), regtype
def clipboard_set(self, lines, regtype, reg):
txt = u'\n'.join([line.decode('utf-8') for line in lines])
if regtype == 'V':
txt = txt + u'\n'
xerox.copy(txt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment