LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   How to copy and paste things between vim and system clipboard (http://www.linuxquestions.org/questions/slackware-14/how-to-copy-and-paste-things-between-vim-and-system-clipboard-669721/)

grissiom 09-13-2008 01:40 PM

How to copy and paste things between vim and system clipboard
 
Can somebody show how to do it under 12.1? Thanks in advance.

gnashley 09-13-2008 02:06 PM

Left click-n-drag to highlight what you want to select. To paste into nearly any other application just click the center mouse button.

T3slider 09-13-2008 02:10 PM

I don't think that works with vim...

As far as I know, vim wasn't compiled with xterm-clipboard enabled, so you'll have an interesting time getting it to work. But I don't use vim at all, so I am probably wrong.

keefaz 09-13-2008 02:10 PM

Sometimes this setting: set mouse=r (in ~/.vimrc) helps when the mouse does not follow

onebuck 09-13-2008 04:55 PM

Hi,

I use 'gpm' and when you select then highlight with the left mouse button you can then pick a point in the same or other application with input mode. You can then insert with the right mouse button. This works in 'vi/elvis' since that's what I use. It will work between M$ and Linux since it is buffered.

Bruce Hill 09-13-2008 05:13 PM

In /usr/share/vim/vimrc you need to comment (using ")
the line about set mouse. Then it will work.

saulgoode 09-13-2008 09:05 PM

In some text editors (vim and mcedit), I find I have to use SHIFT-middleclick in order to paste (as opposed to just middleclick).

ErV 09-13-2008 09:48 PM

Quote:

Originally Posted by grissiom (Post 3279396)
Can somebody show how to do it under 12.1? Thanks in advance.

"+yy or "*yy to copy to clipboard
"+p or "*p to paste from clipboard
See this:
http://lug.wsu.edu/node/1239
http://vim.wikia.com/wiki/Accessing_...stem_clipboard

vim in slackware 12.1 is configured without +xterm_clipboard, so it won't work in terminal version of vim. You might want to rebuild vim from source.
Or use gvim, where this method is supported.

grissiom 09-14-2008 01:31 AM

Thanks guys, thanks for your advices~;)

I've tried set mouse=r and comment mouse settings in /usr/share/vim/vimrc but they don't work. ;(

It seems that it's very hard to send things to clipboard without +xterm_clipboard. But "SHIFT-middleclick" will paste in the input mode and paste words after 'i' or 'c' in the normal mode. It seems "SHIFT-middleclick" just throw strings into the terminal. Maybe we can do the copy in that way?

Yes, Gvim is xterm_clipboard enabled and hornor "+y. But I perfer launch vim while navigating in Konsole and hate the bad appearance of Gvim in a KDE environment.

I see that Vim 7.2 is out. Maybe PatV is preparing an other update?

Thanks.

Cotobear 09-14-2008 01:42 AM

"How to Setup Slackware" - http://www.vcn.bc.ca/~dugan/setting-up-slackware.html

Quote:

Vim

The version of vim that comes with Slackware is compiled without x support. This is to accomodate users who don't run X. Unfortunately, this also means that if you do run X, you can't paste into vim from other X apps. Solve this problem by recompiling vim for X support (pass --with-x to its configure script). This is best done by downloading the entire vim source directory from a Slackware mirror, then editing and running the SlackBuild. After you do so, you'll be able to run the console version of vim inside an xterm, and paste text into it from other X applications.

Bruce Hill 09-14-2008 03:20 AM

This is mighty funny to me, because I can paste into ViM from konsole
or from X apps using the middle button. What am I missing, or rather,
what have I got that you are missing?

I can paste into ViM opened from the KDE menu, or into "vim file" from
konsole, or into vim opened in xterm to and from anywhere.

Code:

mingdao@silas:~$ ls /var/log/packages/vim-
vim-7.1.330-i486-1_slack12.1      vim-gvim-7.1.330-i486-1_slack12.1

Code:

mingdao@silas:~$ less /usr/share/vim/vimrc | grep mouse
" In many terminal emulators the mouse works just fine, thus enable it.
" set mouse=a

As a matter of fact, I've not found anywhere yet that I can't drag
with the left mouse button and paste with middle click.

adriv 09-14-2008 03:55 AM

Quote:

Originally Posted by Bruce Hill (Post 3279829)
This is mighty funny to me, because I can paste into ViM from konsole
or from X apps using the middle button. What am I missing, or rather,
what have I got that you are missing?

I can paste into ViM opened from the KDE menu, or into "vim file" from
konsole, or into vim opened in xterm to and from anywhere.

As a matter of fact, I've not found anywhere yet that I can't drag
with the left mouse button and paste with middle click.

Same here.
Never recompiled vim... :)

keefaz 09-14-2008 04:40 AM

Yes, copy and paste from X apps and the reverse works here too :)
My ~/.vimrc looks like:
Code:

if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
  set fileencodings=utf-8,latin1
endif
set nocompatible
set showmode
set ttyfast
set wildchar=<TAB>
set backspace=indent,eol,start
set nobackup
set history=50
set ruler

" Only do this part when compiled with support for autocommands
if has("autocmd")
  " In text files, always limit the width of text to 78 characters
  autocmd BufRead *.txt set tw=78
  " When editing a file, always jump to the last cursor position
  autocmd BufReadPost *
  \ if line("'\"") > 0 && line ("'\"") <= line("$") |
  \  exe "normal g'\"" |
  \ endif
endif

map Q gq
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch
endif
if &term=="xterm"
    set t_Co=8
    set t_Sb=^[4%dm
    set t_Sf=^[3%dm
endif
set tabstop=4
set autoindent
set mouse=r


grissiom 09-14-2008 04:42 AM

Quote:

Originally Posted by Bruce Hill (Post 3279829)
This is mighty funny to me, because I can paste into ViM from konsole
or from X apps using the middle button. What am I missing, or rather,
what have I got that you are missing?

I can paste into ViM opened from the KDE menu, or into "vim file" from
konsole, or into vim opened in xterm to and from anywhere.

I forgot to mention that I'm using KDE4.1 testing package from slackware.com. But I think it maybe does not metter. On my box, middle click does not paste the words selected outside but same other words which I don't know where they come from. But Shift+middle click dose the work.

Besides, it's also unconvenience if I can only paste things in but cannot get things out.

harryhaller 09-14-2008 04:48 AM

Have you tried using the shift key when selecting/pasting with the mouse?

Some programs such as midnight commander or links require it.

If you're using vim as mc's default editor (export EDITOR="vim"), try starting mc with "mc -d" - this disables the mouse from controlling mc, but allows select/paste without the shift key.

[EDIT] sorry - please ignore - I hadn't seen post #9


All times are GMT -5. The time now is 07:28 AM.