Sunday, August 3, 2014

Re: ssh and star register?

On 03/08/14 20:11, Bee wrote:
> vim version 7.4.383
>
> I use the same vimrc and gvimrc on Linux, Mac, and Win,
> with conditionals to test for the differences.
> It works GREAT with terminal vim and gvim.
>
> The 'problem' is ssh into a Mac, and a test for the star ("*) register.
> In both local and remote terminal vim:
> has("clipboard") returns 1
> has("xterm_clipboard") returns 0
> has("gui_running") returns 0
>
> same machine:
> local terminal "* works
> remote terminal "* fails
>
> How can I test for the ability to use the star ("*) register when ssh?
>

It is not always obvious to detect whether or not a clipboard-enabled
Vim is running in an environment which includes a clipboard.

I use the following in my vimrc, but I won't guarantee that it'll work
for you. Try it, and if it doesn't work for you, try to debug why not.


" (try to) detect whether we have clipboard and X
if has('gui_running')
function TestForX()
return 1
endfunction
elseif has('clipboard')
function TestForX()
let @+ = " "
let x = @+
let @+ = '--' . x
redir @"
silent reg
redir END
let @+ = x
" unlet x
return (@" =~ '\n"+ ')
endfunction
else
function TestForX()
return 0
endfunction
endif
if has('autocmd')
au VimEnter *
\ let clipboard_present = TestForX()
\ | let X_available = has('x11') && clipboard_present
endif



Best regards,
Tony.
--
A Roman divorced from his wife, being highly blamed by his friends, who
demanded, "Was she not chaste? Was she not fair? Was she not fruitful?"
holding out his shoe, asked them whether it was not new and well made.
Yet, added he, none of you can tell where it pinches me.
-- Plutarch

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: