Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to copy text from vim, eg. by selecting in visual mode, then ctrl+insert and I'd like to have the copied text in system buffer, so I can paste it anywhere I like with eg ctrl+v. Is it possible somehow?

Problem arises when I need to copy long text from vim window to buffer. I cannot simply select it all with a mouse and then copy it, because the text doesn't fit in the window.

share|improve this question

migrated from serverfault.com Jul 6 '11 at 13:24

This question came from our site for professional system and network administrators.

add comment

2 Answers

up vote 3 down vote accepted

Yes. Vim has references to the system clipboards as registers, which you can use like any other registers.

The main clipboard is *, so you can highlight in visual mode, then type "*y. If you're using X11 you can copy to the X11 buffer using the + register. Lastly, you can reassign the default register to the clipboard register with :set clipboard=unnamed. If you do this then any copies, yanks, or kills will automatically go to the system clipboard without you manually specifying the register first.

share|improve this answer
    
It worked first time after I rebooted my PC. But after that when I've used console buffer, system buffer, etc, they seems to have mixed up. So now when I do "*y, text doesn't go to system buffer. But X11 buffer + still working fine. Thanks anyway. –  user69817 Jul 7 '11 at 10:44
add comment

The visual selection (v, V, or CTRL-V) can automatically be copied to the X11 selection (* buffer).

In non-gui mode the clipboard option controls this (only supported if +xterm_clipboard appears when you type vim --version). In gui mode guioptions controls it.

This makes all Visual mode selections automatically go to the X11 primary selection:

    set clipboard+=autoselect
    set guioptions+=a

This turns it off:

    set clipboard-=autoselect
    set guioptions-=a

See help 'clipboard' (single quotes required)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.