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 tried to paste what I copied in windows clipboard into cygwin's vi or emacs, and it doesn't seem to work with yy (vi) or M-w (emacs).

Is there a way to do it? I learned that /etc/clipboard has the clipboard data from windows, but I don't know how to get this info in vi or emacs.

share|improve this question
add comment

3 Answers

At least for vim, the clipboard is the "* register.

So, to yank the current line, go "*yy, to paste in the contents of the clipboard, go "*p, so on and so forth.

share|improve this answer
    
I tried, but it doesn't work. Thanks for the answer though. –  prosseek Jul 6 '11 at 14:49
1  
@prosseek; Oh. Well, FWIW, it works in both gvim and the version of vim that comes with it - you could consider using those over cygwin's? –  Phoshi Jul 6 '11 at 15:11
add comment

To paste from the clipboard using vi in Cygwin:

Press SHIFT-INSERT in insert mode

(this means the insert key by the Delete/Home/End keys)

To copy to the clipboard using vi in Cygwin:

When you select text with your mouse, it automatically gets copied to the clipboard.

You can paste from the clipboard by pressing the middle mouse button.

Also, in some environments where "*yy doesn't work, you can try "+yy.

Unfortunately this does NOT work in Cygwin.

share|improve this answer
add comment

There is a solution mentioned in Wikia:

function! Putclip(type, ...) range
  let sel_save = &selection
  let &selection = "inclusive"
  let reg_save = @@
  if a:type == 'n'
    silent exe a:firstline . "," . a:lastline . "y"
  elseif a:type == 'c'
    silent exe a:1 . "," . a:2 . "y"
  else
    silent exe "normal! `<" . a:type . "`>y"
  endif
  call writefile(split(@@,"\n"), '/dev/clipboard')
  let &selection = sel_save
  let @@ = reg_save
endfunction


vnoremap <silent> <leader>y :call Putclip(visualmode(), 1)<CR>
nnoremap <silent> <leader>y :call Putclip('n', 1)<CR>

just copy these lines to .vimrc and your \y will do the trick, whether you are using vim or your mouse to select texts.
This may not be a problem since you already have access to the clipboard, but /dev/clipboard is available for Cygwin version 1.7.13 and higher.

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.