vile
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vile] X copy/paste from xterm vile


From: Daniel L. Ashbrook
Subject: [vile] X copy/paste from xterm vile
Date: Thu, 9 Aug 2007 11:42:17 -0400
User-agent: Mutt/1.4.2.1i

I was discussing vim vs vile vs emacs yesterday with a friend
(explaining how 12 years of finger-feel of vile makes even thinking about
chaning editors crazy) and he mentioned writing some vim macros to access
the X (and OSX) clipboards from vim. He said that the '*' register in vim
mirrors the state of the X clipboard, and under OSX he wrote a macro to
use pbcopy and pbpaste to do the same thing.

That started me trying to figure out how to do the same sort of thing in
vile. I guess one solution would be to allow the console version of vile
to access the X clipboard (much as it changes the xterm title), but I
don't enjoy mucking around with X code particularly so I'll leave that
for Tom. The other solution I thought of was to pipe the contents of the
unamed register (or some other) through the xclip program, which puts
stdin onto the X clipboard (pbcopy does the same sort of thing on OSX)
or puts the X clipboard onto stdout (pbpaste on OSX).

As it turns out, it's been a couple of years since I did vile macro
programming and am apparently quite rusty now. Anyone have any
advice? I started with this:

;;Copy the current copy buffer to the clipboard
store-procedure copy
  set-variable %text &register 0
  shell-command &cat &cat "cat | xclip -i" %text ^D
~endm

but it doesn't seem to quite work. For one, shell-command pauses to give
you a chance to read output, which isn't appropriate in this case. The
other ideal way to do it would be something like

store-procedure copy
        filter-til get-movement-command "xclip -i"
~endm
bind-key copy ^A-^C

and then ^A-^C5} would put the next 5 paragraphs onto the clipboard;
unfortunately for me, get-movement-command doesn't exist.

Any thoughts (or modifications to vile code! get-movement-command would
be useful for a number of other macros I've been contemplating... ) would
be most welcome.



dan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]