Quantcast

vim paste buffer

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

vim paste buffer

Guillaume Bog
Hi everbody,

I'm new on this list. I use vim in a terminal on ubuntu everyday and
still need some help for efficient use. If the file i'm editing is
longer than one screen and I want to paste it somewhere else (say in a
firefox textarea), I have to go out of vim, cat the file i'm editing,
select it and then paste it (with middle mouse button). I now the
visual mode, and how to highlight all (gg v G). But this operation
doesn't fill the proper buffer.

I have searched some tips and vim.org but... Any idea?

Regards,
Guillaume
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: vim paste buffer

Albie Janse van Rensburg
Guillaume Bog wrote:

> Hi everbody,
>
> I'm new on this list. I use vim in a terminal on ubuntu everyday and
> still need some help for efficient use. If the file i'm editing is
> longer than one screen and I want to paste it somewhere else (say in a
> firefox textarea), I have to go out of vim, cat the file i'm editing,
> select it and then paste it (with middle mouse button). I now the
> visual mode, and how to highlight all (gg v G). But this operation
> doesn't fill the proper buffer.
>
> I have searched some tips and vim.org but... Any idea?
>
> Regards,
> Guillaume
>
>
:help x11-selection

in particular

:help quoteplus

You will have to be in either a virtual terminal (in X) or in a gui vim
(gvim), as far as I know.  I am currently on a windows machine, so I can
not verify whether it will work from a "proper" tty (alt-f1 to f6), but
you should be able to select the current file's text into the x11 cut
buffer by typing (in normal mode):

gg"*G

...which you should be able to paste into firefox.

Hope it helps

--
Albie Janse van Rensburg (neonpill)

Registered Linux User 438873 | <http://counter.li.org>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: vim paste buffer

Thomas Michael Engelke
In reply to this post by Guillaume Bog
2007/2/8, Guillaume Bog <[hidden email]>:
> Hi everbody,
>
> I'm new on this list. I use vim in a terminal on ubuntu everyday and
> still need some help for efficient use. If the file i'm editing is
> longer than one screen and I want to paste it somewhere else (say in a
> firefox textarea), I have to go out of vim, cat the file i'm editing,
> select it and then paste it (with middle mouse button). I now the
> visual mode, and how to highlight all (gg v G). But this operation
> doesn't fill the proper buffer.

As I understand it, the register "*" represents the "systemwide
clipboard", whatever that means to the actual OS implementation. So
yanking to the register * should do the trick.

Thomas

--
GPG-Key: tengelke.de/thomas_michael_engelke.asc
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: vim paste buffer

Albie Janse van Rensburg
In reply to this post by Albie Janse van Rensburg
Albie Janse van Rensburg wrote:

> Guillaume Bog wrote:
>> Hi everbody,
>>
>> I'm new on this list. I use vim in a terminal on ubuntu everyday and
>> still need some help for efficient use. If the file i'm editing is
>> longer than one screen and I want to paste it somewhere else (say in a
>> firefox textarea), I have to go out of vim, cat the file i'm editing,
>> select it and then paste it (with middle mouse button). I now the
>> visual mode, and how to highlight all (gg v G). But this operation
>> doesn't fill the proper buffer.
>>
>> I have searched some tips and vim.org but... Any idea?
>>
>> Regards,
>> Guillaume
>>
>>
> :help x11-selection
>
> in particular
>
> :help quoteplus
>
> You will have to be in either a virtual terminal (in X) or in a gui
> vim (gvim), as far as I know.  I am currently on a windows machine, so
> I can not verify whether it will work from a "proper" tty (alt-f1 to
> f6), but you should be able to select the current file's text into the
> x11 cut buffer by typing (in normal mode):
>
> gg"*G
>
> ...which you should be able to paste into firefox.
>
> Hope it helps
>
Whoops.  I meant

gg"*yG

extra: on Windows XP, it also works to use + (a little easier to type), i.e.

gg"+yG

copies the current buffer into the windows clipboard.

--
Albie Janse van Rensburg (neonpill)

Registered Linux User 438873 | <http://counter.li.org>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: vim paste buffer

Kev-13
In reply to this post by Guillaume Bog
Guillaume Bog wrote:

> Hi everbody,
>
> I'm new on this list. I use vim in a terminal on ubuntu everyday and
> still need some help for efficient use. If the file i'm editing is
> longer than one screen and I want to paste it somewhere else (say in a
> firefox textarea), I have to go out of vim, cat the file i'm editing,
> select it and then paste it (with middle mouse button). I now the
> visual mode, and how to highlight all (gg v G). But this operation
> doesn't fill the proper buffer.
>
> I have searched some tips and vim.org but... Any idea?
>
> Regards,
> Guillaume
>
>
Try the following after the ggVG for selecting the entire text: (*note
it is a capital V)
"+y      (this will yank the highlighted text to the system clipboard)
to "paste" something from the system clipboard try:
"+p

I have also added the following to my _vimrc in Windows to use these as
user commands :Co and :Pa .
:command -range Co :norm"+y
:command Pa :norm"+p

Hope this helps,
Kevin
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: vim paste buffer

Kim Schulz
In reply to this post by Guillaume Bog



On Thu, 8 Feb 2007 21:34:12 +0800, "Guillaume Bog" <[hidden email]> wrote:

> Hi everbody,
>
> I'm new on this list. I use vim in a terminal on ubuntu everyday and
> still need some help for efficient use. If the file i'm editing is
> longer than one screen and I want to paste it somewhere else (say in a
> firefox textarea), I have to go out of vim, cat the file i'm editing,
> select it and then paste it (with middle mouse button). I now the
> visual mode, and how to highlight all (gg v G). But this operation
> doesn't fill the proper buffer.
>
> I have searched some tips and vim.org but... Any idea?
>
> Regards,
> Guillaume

just yank it into the "+ register. This is the same as your clipboard.


--
Kim Schulz

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: vim paste buffer

Albie Janse van Rensburg
In reply to this post by Albie Janse van Rensburg
(Copied to group)

Guillaume, just use your mail client's "Reply to all" function if you
don't have a "Reply to list" option, that way the mail will go to the
group, and you will get more answers ;-)

Albie

On 08/02/07, Albie Janse van Rensburg <[hidden email]> wrote:
> gg"*yG
>
> extra: on Windows XP, it also works to use + (a little easier to
> type), i.e.
>
> gg"+yG

Hi, thank for answers. I'm not at work now so I can only try on
Windows with putty term branched on a CentOS server

paste from windows to vim is never a problem, but I can't make it from
vim to outside.

gg"+yG doesn't seem to yank anything

ggVG"+y or ggVG"*y yanks something but I don't get it with ctrl-v

here is my $vim --version
VIM - Vi IMproved 6.3 (2004 June 7, compiled Aug 22 2005 09:38:37)
Included patches: 1-21, 23-24, 26, 28-34, 36-37, 39-40, 42-43, 45-46, 81-82
Modified by <[hidden email]>
Compiled by <[hidden email]>
Huge version without GUI.  Features included (+) or not (-):
+arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset
+cindent
-clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info
+comments
+cryptv +cscope +dialog_con +diff +digraphs -dnd -ebcdic +emacs_tags +eval
+ex_extra +extra_search +farsi +file_in_path +find_in_path +folding -footer
+fork() +gettext -hangul_input +iconv +insert_expand +jumplist +keymap
+langmap
+libcall +linebreak +lispindent +listcmds +localmap +menu +mksession
+modify_fname +mouse -mouseshape +mouse_dec +mouse_gpm -mouse_jsbterm
+mouse_netterm +mouse_xterm +multi_byte +multi_lang -netbeans_intg
-osfiletype
+path_extra +perl +postscript +printer +python +quickfix +rightleft -ruby
+scrollbind +signs +smartindent -sniff +statusline -sun_workshop +syntax
+tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse
+textobjects +title -toolbar +user_commands +vertsplit +virtualedit +visual
+visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup
-X11 -xfontset -xim -xsmp -xterm_clipboard -xterm_save
  system vimrc file: "/etc/vimrc"
    user vimrc file: "$HOME/.vimrc"
     user exrc file: "$HOME/.exrc"
 fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -O2 -g -pipe -m32
-march=i386 -mtune=pentium4 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64
-D_REENTRANT -D_GNU_SOURCE  -pipe -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm
-I/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE
-I/usr/include/python2.3 -pthread
Linking: gcc   -Wl,-E
-Wl,-rpath,/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE
-L/usr/local/lib -o vim       -lncurses -lselinux  -lacl -lgpm -Wl,-E
-Wl,-rpath,/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE
-L/usr/local/lib
/usr/lib/perl5/5.8.5/i386-linux-thread-multi/auto/DynaLoader/DynaLoader.a
-L/usr/lib/perl5/5.8.5/i386-linux-thread-multi/CORE -lperl -lutil -lc
-L/usr/lib/python2.3/config -lpython2.3 -lutil -lm -Xlinker
-export-dynamic


--
Albie Janse van Rensburg (neonpill)

Registered Linux User 438873 | <http://counter.li.org>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: vim paste buffer

Albie Janse van Rensburg

> Hi, thank for answers. I'm not at work now so I can only try on
> Windows with putty term branched on a CentOS server
>
> paste from windows to vim is never a problem, but I can't make it from
> vim to outside.
For this to work, you will have to check with putty how to get data into
the windows clipboard.  It's not a Vim function, which is running inside
the ssh/telnet session you are using.
>
> gg"+yG doesn't seem to yank anything
>
> ggVG"+y or ggVG"*y yanks something but I don't get it with ctrl-v
>

V enters visual mode, and according to the vim help it automatically
copies into the PRIMARY buffer (x11 has 3 clipboards).  Try using gg"*yG
when you get a chance - it copies the entire text into the x11 PRIMARY
buffer, and is faster than using V, which has graphical implications.  
Note again, this will probably not work when using putty for you
terminal, but then again, it might, if you get your settings right.

Hope you find your solution soon

--
Albie Janse van Rensburg (neonpill)

Registered Linux User 438873 | <http://counter.li.org>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: vim paste buffer

Tim Chase-2
In reply to this post by Albie Janse van Rensburg
>> :help x11-selection
>>
>> in particular
>>
>> :help quoteplus

Until I shifted to using *nix boxes regularly (via an actual X
session, rather than remotely accessing via ssh), the distinction
between these registers was lost on me.

On Win32, both the "*" register and the "+" register do the same
thing.  Within X environments, "+" is the clipboard usually
accessed by copy/paste, while "*" is the selection clipboard
(usually filled by selecting stuff, and pasted with the
middle-mouse button).

Thus, depending on what the OP wanted, and how they wanted to
paste (with ^V or Edit|Paste  vs. clicking the middle-mouse
button), it would change which register should be used.

I've had to rewire my hands to use the "+" register because it's
what I usually mean on both systems, and just grew sloppy using
"*" on my win32 boxen.

For this to work, you have to be running a version of vim that
has "+clipboard" enabled in its options.

I haven't had great success with getting cut&paste to work over
an SSH connection from a *nix box to Win32 but there might yet be
some trick I haven't found.

HTH,

-tim


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: vim paste buffer

Guillaume Bog
In reply to this post by Albie Janse van Rensburg
On 08/02/07, Albie Janse van Rensburg <[hidden email]> wrote:

>
> > Hi, thank for answers. I'm not at work now so I can only try on
> > Windows with putty term branched on a CentOS server
> >
> > paste from windows to vim is never a problem, but I can't make it from
> > vim to outside.
> For this to work, you will have to check with putty how to get data into
> the windows clipboard.  It's not a Vim function, which is running inside
> the ssh/telnet session you are using.
> >
> > gg"+yG doesn't seem to yank anything

My bad: it yanks something

> > ggVG"+y or ggVG"*y yanks something but I don't get it with ctrl-v
> >
>
> V enters visual mode, and according to the vim help it automatically
> copies into the PRIMARY buffer (x11 has 3 clipboards).  Try using gg"*yG
> when you get a chance - it copies the entire text into the x11 PRIMARY
> buffer, and is faster than using V, which has graphical implications.
> Note again, this will probably not work when using putty for you
> terminal, but then again, it might, if you get your settings right.

I double checked the many options of my putty but didn't find
anything... Anyway, I don't need that much pasting to windows apps,
and I'll check the gg"*yG on my office computer tomorrow (I'm in China
time).

Thanks again.

Guillaume
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: vim paste buffer

A.J.Mechelynck
In reply to this post by Albie Janse van Rensburg
Albie Janse van Rensburg wrote:
[...]
> here is my $vim --version
> VIM - Vi IMproved 6.3 (2004 June 7, compiled Aug 22 2005 09:38:37)
> Included patches: 1-21, 23-24, 26, 28-34, 36-37, 39-40, 42-43, 45-46, 81-82
> Modified by <[hidden email]>
> Compiled by <[hidden email]>
> Huge version without GUI.  Features included (+) or not (-):
---------------^^^^^^^
[...]
> -clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info
----------------^^^^^^^^^^
[...]
> -X11 -xfontset -xim -xsmp -xterm_clipboard -xterm_save
--^^^^ ---------------------^^^^^^^^^^^^^^^^
[...]

This version of Vim has no clipboard support compiled-in. To be able to paste
from Vim to something else, you need a Vim version capable of accessing the
clipboard. Try invoking "gvim" at your window manager's Alt-F2 "execute"
prompt, rather than (console) Vim at the bash prompt. If you don't have gvim
at all, either install the "vim-x11" RPM, or (recommended) uninstall those
outdated 6.3 versions completely and compile Vim for yourself (see
http://users.skynet.be/antoine.mechelynck/vim/compunix.htm ).

 From gvim, you ought to be able to yank into register + and paste the data
from there into a different application using Ctrl-V or Edit => Paste.


Here is the ":version" output of _my_ gvim. You'll immediately see the
differences.


VIM - Vi IMproved 7.0 (2006 May 7, compiled Feb  7 2007 05:04:54)
Included patches: 1-192
Compiled by [hidden email]
Huge version with GTK2-GNOME GUI.  Features included (+) or not (-):
+arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent
+clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments
+cryptv +cscope +cursorshape +dialog_con_gui +diff +digraphs +dnd -ebcdic
+emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path
+folding -footer +fork() +gettext -hangul_input +iconv +insert_expand
+jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap
+menu +mksession +modify_fname +mouse +mouseshape +mouse_dec +mouse_gpm
-mouse_jsbterm +mouse_netterm +mouse_xterm +multi_byte +multi_lang -mzscheme
+netbeans_intg -osfiletype +path_extra +perl +postscript +printer +profile
+python +quickfix +reltime +rightleft +ruby +scrollbind +signs +smartindent
-sniff +statusline -sun_workshop +syntax +tag_binary +tag_old_static
-tag_any_white +tcl +terminfo +termresponse +textobjects +title +toolbar
+user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace
+wildignore +wildmenu +windows +writebackup +X11 -xfontset +xim +xsmp_interact
+xterm_clipboard -xterm_save
    system vimrc file: "$VIM/vimrc"
      user vimrc file: "$HOME/.vimrc"
       user exrc file: "$HOME/.exrc"
   system gvimrc file: "$VIM/gvimrc"
     user gvimrc file: "$HOME/.gvimrc"
     system menu file: "$VIMRUNTIME/menu.vim"
   fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_GTK  -DXTHREADS
-D_REENTRANT -DXUSE_MTSAFE_API -I/opt/gnome/include/gtk-2.0
-I/opt/gnome/lib/gtk-2.0/include -I/usr/X11R6/include
-I/opt/gnome/include/atk-1.0 -I/opt/gnome/include/pango-1.0
-I/usr/include/freetype2 -I/usr/include/freetype2/config
-I/opt/gnome/include/glib-2.0 -I/opt/gnome/lib/glib-2.0/include   -DORBIT2=1
-pthread -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API -I/usr/include/libart-2.0
-I/usr/include/libxml2 -I/opt/gnome/include/libgnomeui-2.0
-I/opt/gnome/include/libgnome-2.0 -I/opt/gnome/include/libgnomecanvas-2.0
-I/opt/gnome/include/gtk-2.0 -I/opt/gnome/include/gconf/2
-I/opt/gnome/include/libbonoboui-2.0 -I/opt/gnome/include/glib-2.0
-I/opt/gnome/lib/glib-2.0/include -I/opt/gnome/include/orbit-2.0
-I/opt/gnome/include/libbonobo-2.0 -I/opt/gnome/include/gnome-vfs-2.0
-I/opt/gnome/lib/gnome-vfs-2.0/include
-I/opt/gnome/include/bonobo-activation-2.0 -I/opt/gnome/include/pango-1.0
-I/usr/include/freetype2 -I/opt/gnome/lib/gtk-2.0/include -I/usr/X11R6/include
-I/opt/gnome/include/atk-1.0 -I/usr/include/freetype2/config     -O2
-fno-strength-reduce -Wall  -I/usr/X11R6/include   -D_REENTRANT -D_GNU_SOURCE
-DTHREADS_HAVE_PIDS -DDEBUGGING  -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
-I/usr/lib/perl5/5.8.6/i586-linux-thread-multi/CORE  -I/usr/include/python2.4
-pthread -I/usr/include  -D_LARGEFILE64_SOURCE=1  -I/usr/lib/ruby/1.8/i686-linux
Linking: gcc -L/opt/gnome/lib   -L/usr/X11R6/lib   -rdynamic  -Wl,-E
-Wl,-rpath,/usr/lib/perl5/5.8.6/i586-linux-thread-multi/CORE  -rdynamic
-Wl,-E -Wl,-rpath,/usr/lib/perl5/5.8.6/i586-linux-thread-multi/CORE
-L/usr/local/lib -o vim   -L/opt/gnome/lib -lgtk-x11-2.0 -lgdk-x11-2.0
-latk-1.0 -lgdk_pixbuf-2.0 -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0
-lgobject-2.0 -lgmodule-2.0 -lglib-2.0   -L/opt/gnome/lib -L/usr/X11R6/lib
-lgnomeui-2 -lbonoboui-2 -lxml2 -lz -lgnomecanvas-2 -lgnome-2 -lpopt
-lart_lgpl_2 -lpangoft2-1.0 -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0
-lgdk_pixbuf-2.0 -lpangoxft-1.0 -lpangox-1.0 -lpango-1.0 -lgobject-2.0
-lgnomevfs-2 -lbonobo-2 -lgconf-2 -lbonobo-activation -lORBit-2 -lgmodule-2.0
-lgthread-2.0 -lglib-2.0   -lXt -lncurses -lacl -lgpm -Wl,-E
-Wl,-rpath,/usr/lib/perl5/5.8.6/i586-linux-thread-multi/CORE
/usr/lib/perl5/5.8.6/i586-linux-thread-multi/auto/DynaLoader/DynaLoader.a
-L/usr/lib/perl5/5.8.6/i586-linux-thread-multi/CORE -lperl -lutil -lc
-L/usr/lib/python2.4/config -lpython2.4 -lutil -Xlinker -export-dynamic
-L/usr/lib -ltcl8.4 -lieee -lruby -lm


Best regards,
Tony.
--
hundred-and-one symptoms of being an internet addict:
22. You've already visited all the links at Yahoo and you're halfway through
     Lycos.
Loading...