You are not logged in.

#1 2011-08-19 14:26:03

TheImmortalPhoenix
Member
From: 127.0.0.1
Registered: 2011-08-13
Posts: 436

[SOLVED] How can i paste text from vim to another application?

Hi to all men....i've a matter that i cannot resolve....i'd like to know ho to copy text from vim and past it to another application such as pidgin or firefox etc....i've tried to use clipboard manager such as parcellite and xclip but they don't work...i use openbox and the terminale is urxvt-256colors .... Could you help me to resolve the problem? Thanks

Last edited by TheImmortalPhoenix (2011-08-20 02:28:50)

Offline

#2 2011-08-19 14:28:58

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How can i paste text from vim to another application?

I select (highlight) text in vim with the mouse and press the middle (i.e. third) mouse button to paste in Firefox.
It works the other way round too.

Offline

#3 2011-08-19 14:43:22

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: [SOLVED] How can i paste text from vim to another application?

Depending on your system (and sometimes the phase of the moon, I think), if you highlight in visual mode and then hit either "+y or "*y it should copy that text so you can paste it to another X program using shift-insert.

Good luck!
Scott

Offline

#4 2011-08-19 14:55:21

TheImmortalPhoenix
Member
From: 127.0.0.1
Registered: 2011-08-13
Posts: 436

Re: [SOLVED] How can i paste text from vim to another application?

Don't work......i've also installed urxvt-clipboard and insert "URxvt*perl-ext-common: default,matcher,clipboard" in my .Xdefaults but it didn't work.....

Offline

#5 2011-08-19 14:57:01

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [SOLVED] How can i paste text from vim to another application?

It's the default mode in X, I don't have any clipboard, xclip etc. stuff and it works for me.
Shift-Insert does the same as Middle-Mouse-Button.

BTW, where did you get urxvt-256colors from?
rxvt-unicode from the repos is built w/ 256 colors enabled http://projects.archlinux.org/svntogit/ … k/PKGBUILD

Last edited by karol (2011-08-19 14:58:53)

Offline

#6 2011-08-19 15:02:14

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: [SOLVED] How can i paste text from vim to another application?

firecat53 wrote:

Depending on your system (and sometimes the phase of the moon, I think), if you highlight in visual mode and then hit either "+y or "*y it should copy that text so you can paste it to another X program using shift-insert.

Good luck!
Scott

Shift-Insert doesn't always work - for instance, you need to use mouse middle-click (button 2) to paste X PRIMARY selection to firefox.

I've tested with `vim -u NONE --noplugin`, and it works for me:
I just need to select text in visual mode or with mouse (and nothing else), and the text is in my X PRIMARY selection. I confirm this by pasting the text to urxvt using Shift-Insert (and yes, here it is the same with button 2), or `xsel -op`, or `xclip -o --selection primary`.

The VIM help on "clipboard", "x11-selection" and "x11-cut-buffer" are fairly helpful, if it somehow doesn't work for you by default...

Last edited by lolilolicon (2011-08-19 15:07:10)


This silver ladybug at line 28...

Offline

#7 2011-08-19 15:03:03

roygbiv
Member
Registered: 2011-05-18
Posts: 204

Re: [SOLVED] How can i paste text from vim to another application?

karol wrote:

I select (highlight) text in vim with the mouse and press the middle (i.e. third) mouse button to paste in Firefox.
It works the other way round too.

I'm having the same issue here, but highlighting text in vim with the mouse only seems to work without having it enabled in vim:

"set mouse=a

With this option enabled the mouse does only select the text in visual mode, and does not copy it to a clipboard. I'm not sure here.

Offline

#8 2011-08-19 15:36:38

TheImmortalPhoenix
Member
From: 127.0.0.1
Registered: 2011-08-13
Posts: 436

Re: [SOLVED] How can i paste text from vim to another application?

karol wrote:

BTW, where did you get urxvt-256colors from?
rxvt-unicode from the repos is built w/ 256 colors enabled http://projects.archlinux.org/svntogit/ … k/PKGBUILD

My mistake, i ment rxvt-unicode...

lolilolicon wrote:

Shift-Insert doesn't always work - for instance, you need to use mouse middle-click (button 2) to paste X PRIMARY selection to firefox.

I've tested with `vim -u NONE --noplugin`, and it works for me:
I just need to select text in visual mode or with mouse (and nothing else), and the text is in my X PRIMARY selection. I confirm this by pasting the text to urxvt using Shift-Insert (and yes, here it is the same with button 2), or `xsel -op`, or `xclip -o --selection primary`.

The VIM help on "clipboard", "x11-selection" and "x11-cut-buffer" are fairly helpful, if it somehow doesn't work for you by default...

If i use 'vim -u NONE --noplugin' it works....but i can't use vim without plugins...it's not suitable for me....

Offline

#9 2011-08-19 15:41:20

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: [SOLVED] How can i paste text from vim to another application?

firecat53 wrote:

Depending on your system (and sometimes the phase of the moon, I think), if you highlight in visual mode and then hit either "+y or "*y it should copy that text so you can paste it to another X program using shift-insert.

You need to have the gvim package installed for that, the standard vim doesn't come with X-buffers compiled.


ᶘ ᵒᴥᵒᶅ

Offline

#10 2011-08-19 15:50:28

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: [SOLVED] How can i paste text from vim to another application?

TheImmortalPhoenix wrote:

If i use 'vim -u NONE --noplugin' it works....but i can't use vim without plugins...it's not suitable for me....

Well, me neither. I did that just to make sure the default works. So maybe it's your .vimrc? Try `vim -u NONE`.

@litemotiv Yeah, that's what I thought...


This silver ladybug at line 28...

Offline

#11 2011-08-19 15:53:28

TheImmortalPhoenix
Member
From: 127.0.0.1
Registered: 2011-08-13
Posts: 436

Re: [SOLVED] How can i paste text from vim to another application?

This is my .vimrc:

" Basics
syntax on               " enable syntax highlighting
set showmatch           " show matching brackets (),{},[]
set number
set nocompatible
set background=dark
set encoding=utf-8
set termencoding=utf-8 
set shell=/bin/zsh
set mouse=a
set noswapfile
filetype on
set complete=k          " global autocompletion
set completeopt+=longest

" Indenting, Folding..
set tabstop=4           " numbers of spaces of tab character
set shiftwidth=4        " numbers of spaces to (auto)indent
set softtabstop=4       " counts n spaces when DELETE or BCKSPCE is used
set expandtab           " insert spaces instead of tab chars
set autoindent         	" always set autoindenting on
set nosmartindent       " intelligent indenting -- DEPRECATED by cindent
set nocindent           " set C style indenting off
set foldenable
set foldmethod=marker

" searching
set hlsearch            " highlight all search results
set incsearch           " increment search
set ignorecase          " case-insensitive search
set smartcase           " upper-case sensitive search

set laststatus=2        " occasions to show status line, 2=always.
" set cmdheight=1         " command line height
set ruler               " ruler display in status line
set showmode            " show mode at bottom of screen
" set previewheight=5

" Set taglist plugin options
let Tlist_Use_Right_Window = 1
let Tlist_Exit_OnlyWindow = 1
let Tlist_Enable_Fold_Column = 0
let Tlist_Compact_Format = 1
let Tlist_File_Fold_Auto_Close = 0
let Tlist_Inc_Winwidth = 1

" Toggle taglist script
map <F7> :Tlist<CR>

" VTreeExplorer
map <F12> :VSTreeExplore <CR>
let g:treeExplVertical=1
let g:treeExplWinSize=35
let g:treeExplDirSort=1

" common save shortcuts
" inoremap <C-s> <esc>:w<cr>a
" nnoremap <C-s> :w<cr>

" Set bracket matching and comment formats
set matchpairs+=<:>
set comments-=s1:/*,mb:*,ex:*/
set comments+=s:/*,mb:**,ex:*/
set comments+=fb:*
set comments+=b:\"
set comments+=n::

" Fix filetype detection
au BufNewFile,BufRead .torsmorc* set filetype=rc
au BufNewFile,BufRead *.inc set filetype=php
au BufNewFile,BufRead *.sys set filetype=php
au BufNewFile,BufRead grub.conf set filetype=grub
au BufNewFile,BufRead *.dentry set filetype=dentry
au BufNewFile,BufRead *.blog set filetype=blog

" C file specific options
au FileType c,cpp set cindent
au FileType c,cpp set formatoptions+=ro

" HTML abbreviations
au FileType html,xhtml,php,eruby imap bbb <br />
au FileType html,xhtml,php,eruby imap aaa <a href=""><left><left>
au FileType html,xhtml,php,eruby imap iii <img src="" /><left><left><left><left>
au FileType html,xhtml,php,eruby imap ddd <div class=""><left><left>

" Session Settings
set sessionoptions=blank,buffers,curdir,folds,help,resize,tabpages,winsize
map <c-q> :mksession! ~/.vim/.session <cr>
map <c-s> :source ~/.vim/.session <cr>

" Set up the status line
fun! <SID>SetStatusLine()
    let l:s1="%-3.3n\\ %f\\ %h%m%r%w"
    let l:s2="[%{strlen(&filetype)?&filetype:'?'},%{&encoding},%{&fileformat}]"
    let l:s3="%=\\ 0x%-8B\\ \\ %-14.(%l,%c%V%)\\ %<%P"
    execute "set statusline=" . l:s1 . l:s2 . l:s3
endfun
set laststatus=2
call <SID>SetStatusLine()

" Turn off blinking
"set visualbell
" Turn off beep
"set noerrorbells
set vb      " don't beep
set t_vb=   " ^

" highlight redundant whitespaces and tabs.
" highlight RedundantSpaces ctermbg=red guibg=red
" match RedundantSpaces /\s\+$\| \+\ze\t\|\t/

if has('gui_running')
    let &guicursor = &guicursor . ",a:blinkon0"
    colorscheme candycode
    set guifont=Monaco\ 9
    set guioptions-=T
    "set guioptions+=g
    "set guioptions-=t
    "set guioptions-=m
    set guioptions-=L
    set guioptions-=l
    set guioptions-=r
    set guioptions-=R
    set guitablabel=%t " set label for tab to just file name
    set anti " Antialias font
    "set transparency=0
elseif (&term =~ 'linux')
    set t_Co=16
    set termencoding=utf-8
    set nocursorline
    colorscheme desert
else
    set t_Co=256
    set mouse=a         
    colorscheme gigamo
    set termencoding=utf-8 
endif

Is there something to fix?

Also "vim -u NONE" is not suitable for me...

Last edited by TheImmortalPhoenix (2011-08-19 15:56:20)

Offline

#12 2011-08-19 15:56:31

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: [SOLVED] How can i paste text from vim to another application?

litemotiv wrote:
firecat53 wrote:

Depending on your system (and sometimes the phase of the moon, I think), if you highlight in visual mode and then hit either "+y or "*y it should copy that text so you can paste it to another X program using shift-insert.

You need to have the gvim package installed for that, the standard vim doesn't come with X-buffers compiled.

Oh yeah! I forgot I had installed that for the python support but I only actually use console vim!

Scott

Offline

#13 2011-08-19 16:37:01

lolilolicon
Member
Registered: 2009-03-05
Posts: 1,722

Re: [SOLVED] How can i paste text from vim to another application?

TheImmortalPhoenix wrote:

This is my .vimrc:
-----8<-----
Is there something to fix?

I don't see any.

TheImmortalPhoenix wrote:

Also "vim -u NONE" is not suitable for me...

It's not about about suitable or not... it's about debugging. You said `vim -u NONE --noplugins` worked for you, so it's either your .vimrc OR some plugin that messes it up. You try `vim -u NONE` and `vim --noplugins` to find out which...


This silver ladybug at line 28...

Offline

#14 2011-08-19 17:15:26

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: [SOLVED] How can i paste text from vim to another application?

To copy from an xterm vim, I hold down Shift while I highlight text with the mouse.  This stops vim from entering Visual mode.  Whatever I highlight becomes the primary selection.

To paste a primary selection in xterm vim, I first make sure vim is in 'Insert' mode.  Shift+Insert will then paste the primary selection at the cursor.

Offline

#15 2011-08-19 18:08:38

TheImmortalPhoenix
Member
From: 127.0.0.1
Registered: 2011-08-13
Posts: 436

Re: [SOLVED] How can i paste text from vim to another application?

thisoldman wrote:

To copy from an xterm vim, I hold down Shift while I highlight text with the mouse.  This stops vim from entering Visual mode.  Whatever I highlight becomes the primary selection.

To paste a primary selection in xterm vim, I first make sure vim is in 'Insert' mode.  Shift+Insert will then paste the primary selection at the cursor.


Great!! This work for me!! Thank you very much!!

But it works only with the mouse....if i'd like to use just keyboard in tiling wms what could i do?

Just another question: in the .vimrc which voice i have to delete in order to eliminate showing line numbers on the left?

Last edited by TheImmortalPhoenix (2011-08-19 18:17:33)

Offline

#16 2011-08-19 18:19:36

frabjous
Member
Registered: 2010-07-13
Posts: 367

Re: [SOLVED] How can i paste text from vim to another application?

Just another question: in the .vimrc which voice i have to delete in order to eliminate showing line numbers on the left?

Remove:

set number

or possibly change it to:

set nonumber

Offline

#17 2011-08-19 23:01:56

thisoldman
Member
From: Pittsburgh
Registered: 2009-04-25
Posts: 1,172

Re: [SOLVED] How can i paste text from vim to another application?

In 'command mode', for toggling line numbers:

:set nonu            Turns off line numbering.
:set nu              Turns line numbering on.

Getting copy and paste in vim to use the clipboard – what I've learned but haven't tried to change:

The version of vim shipped by Arch is compiled without the 'xterm_clipboard' feature support.  You can see this when you type the command, 'vim --version'.  Features that are supported have a '+' in front of them and features not supported have a '-' in front of them.

If the 'xterm_clipboard' were enabled, special vim registers would connect to the cut-buffers and X11's selection buffer.  You could then copy into a vim register without using the mouse and have the copied text available for pasting into a GUI app.  See http://www.jveweb.net/en/archives/2011/ … board.html.  This is not possible with the vanilla Arch package.

The best work-around might be recompiling using ABS and modifying the PKGBUILD.  See this thread, https://bbs.archlinux.org/viewtopic.php?id=104903, and this bug report / feature request, https://bugs.archlinux.org/task/22612.

Edit: Corrected where I wrote "xterm" but meant "vim".

Last edited by thisoldman (2011-08-20 00:37:06)

Offline

#18 2011-08-19 23:17:36

TheImmortalPhoenix
Member
From: 127.0.0.1
Registered: 2011-08-13
Posts: 436

Re: [SOLVED] How can i paste text from vim to another application?

Thanks for clearing my doubts!! I'll recompile vim wink

Offline

#19 2011-08-20 00:32:26

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: [SOLVED] How can i paste text from vim to another application?

Fyi, You can just install gvim instead of recompiling if you so desire. The console vim installed with gvim comes compiled with that X clipboard support.

Scott

Offline

#20 2011-08-20 02:10:42

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: [SOLVED] How can i paste text from vim to another application?

My suggestion: Install the gvim package and use "* and "+ (eg "*p to paste into vim)
See :h quotestar for more info.

Recompiling the vim package to add +X11 stuff is imo silly compared to just using the gvim package. (as said, it does provide a 'vim' binary with all the nice stuff included)

Last edited by Mr.Elendig (2011-08-20 02:12:10)


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#21 2011-08-20 02:28:18

TheImmortalPhoenix
Member
From: 127.0.0.1
Registered: 2011-08-13
Posts: 436

Re: [SOLVED] How can i paste text from vim to another application?

I recompiled smile i use awesome wm and i mostly use terminal...so i don't want gtk applications...however the problem is solved now! Thanks to all of you have helped me smile

Offline

#22 2011-08-20 02:40:42

Mr.Elendig
#archlinux@freenode channel op
From: The intertubes
Registered: 2004-11-07
Posts: 4,092

Re: [SOLVED] How can i paste text from vim to another application?

As if you were going to miss those 3mb of disk space tongue


Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest

Offline

#23 2011-08-20 12:48:47

TheImmortalPhoenix
Member
From: 127.0.0.1
Registered: 2011-08-13
Posts: 436

Re: [SOLVED] How can i paste text from vim to another application?

Mr.Elendig wrote:

As if you were going to miss those 3mb of disk space tongue

It's not about space, but appearance tongue

Offline

#24 2011-08-20 14:17:30

Gooru
Member
From: Poland
Registered: 2010-08-25
Posts: 53

Re: [SOLVED] How can i paste text from vim to another application?

Maybe too late, but you may consider rebuilding vim with --with-x=yes option.
Read this: https://bbs.archlinux.org/viewtopic.php?id=71619
It solved the same problem at my computer ;]

Offline

#25 2011-08-20 14:46:20

TheImmortalPhoenix
Member
From: 127.0.0.1
Registered: 2011-08-13
Posts: 436

Re: [SOLVED] How can i paste text from vim to another application?

Gooru wrote:

Maybe too late, but you may consider rebuilding vim with --with-x=yes option.
Read this: https://bbs.archlinux.org/viewtopic.php?id=71619
It solved the same problem at my computer ;]

That's what i've done smile

Offline

Board footer

Powered by FluxBB