Loading ...
Sorry, an error occurred while loading the content.

ssh and star register?

Expand Messages
  • Bee
    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
    Message 1 of 6 , Aug 3, 2014
    • 0 Attachment
      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?

      --
      --
      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@....
      For more options, visit https://groups.google.com/d/optout.
    • Tony Mechelynck
      ... 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
      Message 2 of 6 , Aug 3, 2014
      • 0 Attachment
        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@....
        For more options, visit https://groups.google.com/d/optout.
      • Bee
        @Tony Thank you, your test looking at the register list works. I tried in vimrc: ``` let @* = star echo @* ``` and it returned star but after vim started,
        Message 3 of 6 , Aug 4, 2014
        • 0 Attachment
          @Tony Thank you, your test looking at the register list works.

          I tried in vimrc:
          ```
          let @* = 'star'
          echo @*
          ```
          and it returned 'star'
          but after vim started, there was no @* in the register list!

          Do you know how/why the star register is working before vim is fully started but not after?

          This is the updated test for 'clipboard'.
          It now works in local terminal and remote ssh.

          " .......1.........2.........3..
          if has("clipboard")
          let @- = @* " save system clipboard
          let @* = 'star' | redir @" | silent reg | redir END
          if @" =~ '\n"* '
          let @* = @- " restore system clipboard
          vmap ,y "+y
          nmap ,p "+gP
          " exclude:{pattern} must be last ^= prepend += append
          set clipboard-=autoselect
          set clipboard^=unnamed
          if has("gui_running") || has("xterm_clipboard")
          silent! set clipboard^=unnamedplus
          endif
          endif
          elseif has("macunix")
          vmap ,y :write !pbcopy<cr><cr>
          endif
          " .......1.........2.........3..

          --
          --
          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@....
          For more options, visit https://groups.google.com/d/optout.
        • Bee
          Well... It is NOT working everywhere. :( -- -- You received this message from the vim_use maillist. Do not top-post! Type your reply below the text you are
          Message 4 of 6 , Aug 4, 2014
          • 0 Attachment
            Well...
            It is NOT working everywhere. :(

            --
            --
            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@....
            For more options, visit https://groups.google.com/d/optout.
          • Tony Mechelynck
            ... IIUC, empty registers are not listed. I m not sure which circumstances can clear the star register, considering that (in X11) selecting anything in any
            Message 5 of 6 , Aug 4, 2014
            • 0 Attachment
              On 04/08/14 17:30, Bee wrote:
              > @Tony Thank you, your test looking at the register list works.
              >
              > I tried in vimrc:
              > ```
              > let @* = 'star'
              > echo @*
              > ```
              > and it returned 'star'
              > but after vim started, there was no @* in the register list!
              >
              > Do you know how/why the star register is working before vim is fully started but not after?

              IIUC, empty registers are not listed. I'm not sure which circumstances
              can clear the star register, considering that (in X11) selecting
              anything in any program (except in Vim if 'clipboard' does not include
              "autoselect" and 'guioptions' does not include the a flag) makes that
              program the owner of the X selection and sets the X selection to the
              value of the selected area.

              The star register cannot thus be used to hold anything for any length of
              time: any selection in any program will replace it. The + register is
              somewhat longer-term but not much; at least changing the clipboard
              contents usually requires an explicit action.


              Best regards,
              Tony.
              --
              All things are possible, except for skiing through a revolving door.

              --
              --
              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@....
              For more options, visit https://groups.google.com/d/optout.
            • Bee
              @Tony, thank you for the autocmd hint. This time it is working as I expect, local terminal and ssh. autocmd VimEnter * let @- = @* | silent! let @* = star
              Message 6 of 6 , Aug 5, 2014
              • 0 Attachment
                @Tony, thank you for the autocmd hint.

                This time it is working as I expect, local terminal and ssh.

                autocmd VimEnter *
                \ let @- = @* | silent! let @* = 'star'
                \| if @* == 'star' | let @* = @-
                \| set cb^=unnamed cb^=unnamedplus cb+=autoselect
                \| endif

                --
                --
                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@....
                For more options, visit https://groups.google.com/d/optout.
              Your message has been successfully submitted and would be delivered to recipients shortly.