How to copy and paste things between vim and system clipboard
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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?
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.
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.
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.
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
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.
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
Last edited by harryhaller; 09-14-2008 at 06:00 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.