On Windows (from cygwin):
vmap <C-c> :<Esc>`>a<CR><Esc>mx`<i<CR><Esc>my'xk$v'y!cat >/dev/clipboard<CR>u
On Linux machines (if you have xclip):
vmap <C-c> :<Esc>`>a<CR><Esc>mx`<i<CR><Esc>my'xk$v'y!xclip -selection c<CR>u
I think to copy only part of the line, I had to use marks to keep
track of the selection length, otherwise the cat or xclip command is
executed on the whole line. Also copying wiped out the line that I
was on, so I had to undo the command after the copy.
I think there is a buffer in vi that corresponds to the system
clipboard, but couldn't get that to work either. Yes it's an ugly
sequence of commands, but once it's in in my .vimrc I can copy and
paste from vi into other applications both on my Windows and Linux
machines
Thanks,
Ven
If you have to do all that to copy from vim to the clipboard, your
system is not properly configured. It may be that the vi or vim
you're using was not built with support for X11 or the
xterm_clipboard. Some distributions come with a "vi" that is the
tiny version of Vim, without support many features at all, and "vim"
is often built without support for X11. Try running Vim in a
terminal as "gvim -v". That will use the gvim binary, which does
have X11 support, but in console mode.
Regards,
Gary
> same issue when I was. Does anyone know if there are
> alternatives to Cygwin that could give a Windows user a *nix
> command line that one could access via Gvim, with a good set
> of utilities that would integrate more easily with the
> Windows clipboard? I'm trying to avoid Cygwin (too slow, and
> I found the installation a pain) but I've been wanting to try
> to learn some bash scripting. Having a decent terminal
> emulator would be a plus too -- is Cygwin my only option?
i found i could be most productive in the windows shell -- i
forget if it was cmd.exe or command.com
with the utilities from
http://unxutils.sourceforge.net
installed in your path, you'll be amazed what you can do
sc
There is a patch, that enables Cygwin vim to access the windows
clipboard.
http://groups.google.com/group/vim_dev/web/vim-patches
regards,
Christian
Can't it do that by default? I thought /dev/clipboard is available
when you install Cygwin, and points to the windows clipboard.
Thanks,
Ven
>
> regards,
> Christian
>
I have no clue how my system is configured, but I'm almost positive
that there's something wrong
with my vi setup.
> you're using was not built with support for X11 or the
> xterm_clipboard. Some distributions come with a "vi" that is the
> tiny version of Vim, without support many features at all, and "vim"
> is often built without support for X11. Try running Vim in a
> terminal as "gvim -v". That will use the gvim binary, which does
Wow, thank you so much for that tip - You have no idea how many hours
I spent trying to get copy and paste to work. When I tried gvim -v, I
was able to access the +buffer to copy. Could you please add this to
the vim wiki, because I think it could seriously benefit a lot of
users.
Except now I have a slight problem that when I try to do shift+F4,
which I mapped to a shortcut, it prints out "2S" on the line. This
worked fine when I ran vi before, but it looks like some sort of weird
keymapping issue.
I hope the rest of the features work as expected. Does running gvim
-v require X11? I'm wondering if it will still work when I ssh into a
remote machine.
> have X11 support, but in console mode.
>
> Regards,
> Gary
>
Thanks,
Ven
> Except now I have a slight problem that when I try to do
> shift+F4, which I mapped to a shortcut, it prints out "2S" on
> the line. This worked fine when I ran vi before, but it looks
> like some sort of weird keymapping issue.
if you still have
set paste
in your .vimrc, take it out
sc
> I hope the rest of the features work as expected. Does running gvim
> -v require X11? I'm wondering if it will still work when I ssh into a
> remote machine.
No, it does not require X11 to run, it just makes use of certain X11
features if they are available.
Using it over an ssh connection should work fine except for those
features that require X11. I _think_ that you can use those
features over as ssh connection as well if you use ssh's -Y option,
but I can't test that at the moment.
Regards,
Gary
Don't know. I've never had the need for the feature.
> I thought /dev/clipboard is available
> when you install Cygwin, and points to the windows clipboard.
Have you tried the patch? If enough people test the patch and report back
that it works without any problems, there is a good chance, that
the patch will eventually be included into main Vim. Or to say it with
other words: Vim is OpenSource, it's your chance to give something back ;)
regards,
Christian
You might also want to try the vim-dev mailinglist. In either way, please
report back there, so Bram will know about the status of the patch and
if it works without problems, might eventually include it.
regards,
Christian
Well, I took a look and could successfully patch Vim 7.3 sources with
the simple patch. The patch applied with offsets and I needed to
manually patch config.h.in but after fixing that, it compiled
successfully. How can I test, that it works? Do I need to compile a
Cygwin binary or the Windows binary?
I simply cross compiled a Windows binary. If I need to compile a Cygwin
binary, I need to start all over again on Windows and need to get all
available tools for Cygwin, which I feel is really painful ;(
regards,
Christian
On Mo, 18 Okt 2010, Sean wrote:
> What is wrong with these steps?
>
> --------------------------------
> cd /usr/share/vim
> hg pull -u
> cd /usr/share/vim/src
> patch -f <
> vim_on_cygwin_using_win32_clipboard__simple__2008_12_21_001.patch >&
> logfile
> --------------------------------
Are you missing a -p0 as paramter to patch?
I could successfully patch the source, but hadn't had luck compiling it
on Cygwin. BTW: I think the simple patch is wrong. It changes the
configure script, which you wouldn't use when compiling on Cygwin (there
you would use Make_cyg.mak), and which in turn breaks compiling a unix
binary.
I tried compiling on Cygwin, but linking fails miserably ;(
regards,
Christian