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

Re: MacVim @+ register not copied to the clipboard

Expand Messages
  • björn
    ... It works fine for me so I am guessing that we are talking about different versions. Are you using this: http://code.google.com/p/macvim/ The older Carbon
    Message 1 of 15 , Apr 5, 2009
    • 0 Attachment
      2009/4/5 pr3d4t0r:
      >
      > I wrote a script that uses the @+ to copy a string to the clipboard.
      > The strings are not being copied for some reason under the latest
      > stable MacVim.
      >
      > Here is the code:
      >
      >      if has("gui_running")
      >        let clipboardContents = split(location, " ")
      >        let @+                = clipboardContents[0x01]
      >      endif
      >
      > The same code works fine under gvim in OS X, Linux, and Windows.
      >
      > I tried setting @+ from the : command prompt as well:
      >
      > :let @+ = "this is a test."
      >
      > It doesn't work either.  Please advise and thanks in advance!

      It works fine for me so I am guessing that we are talking about
      different versions. Are you using this:

      http://code.google.com/p/macvim/

      The older Carbon version of Vim is not supported anymore and has
      problems with the pasteboard in Terminal mode whereas MacVim.app can
      handle the clipboard both in GUI and Terminal mode.

      Björn

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_mac" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • björn
      ... I forgot to say that clipboard in Terminal mode only works with the snapshot -- the stable branch only supports clipboard in GUI mode. Björn
      Message 2 of 15 , Apr 5, 2009
      • 0 Attachment
        > The older Carbon version of Vim is not supported anymore and has
        > problems with the pasteboard in Terminal mode whereas MacVim.app can
        > handle the clipboard both in GUI and Terminal mode.

        I forgot to say that clipboard in Terminal mode only works with the
        snapshot -- the stable branch only supports clipboard in GUI mode.

        Björn

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_mac" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • björn
        ... John, As far as I can tell those tips are completely outdated. There is a clipboard on Mac OS X and MacVim.app uses it properly -- there is no need to use
        Message 3 of 15 , Apr 5, 2009
        • 0 Attachment
          2009/4/5 John Beckett:
          >
          > pr3d4t0r wrote:
          >> :let @+ = "this is a test."
          >>
          >> It doesn't work either.
          >
          > I hope someone will sort this out and fix the following tips:
          >
          > http://vim.wikia.com/wiki/Mac_OS_X_clipboard_sharing
          > http://vim.wikia.com/wiki/In_line_copy_and_paste_to_system_clipboard
          >
          > I do NOT want to support old systems on the Vim Tips wiki, so
          > I'd appreciate it if someone would either fix the above, or tell
          > me what needs to be done. Obsolete and misguided info should be
          > deleted.
          >
          > Does MacVim show '+clipboard' for the :version command?

          John,

          As far as I can tell those tips are completely outdated. There is a
          clipboard on Mac OS X and MacVim.app uses it properly -- there is no
          need to use "pbcopy/pbpaste". I already said this in another post but
          interaction with the pasteboard is fully supported in both GUI and
          terminal mode (the latter only if you are using the latest snapshot
          version). The "+" and "*" registers are one and the same and by
          default you can use <D-x>/<D-c>/<D-v> to cut/copy/paste just like in
          any other Mac app.

          Björn

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_mac" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • pr3d4t0r
          ... OKi, here we go: 1. This is on MacVim 7.2 stable 1.2 (33.3) 2. +clipboard is set when I run :version 3. Select/yank, select/Cmd-C, select/copy-icon only
          Message 4 of 15 , Apr 5, 2009
          • 0 Attachment
            On Apr 5, 4:43 am, björn <bjorn.winck...@...> wrote:
            > 2009/4/5 John Beckett:
            > > pr3d4t0r wrote:
            > >> :let @+ = "this is a test."
            >
            > > Does MacVim show '+clipboard' for the :version command?
            >
            > As far as I can tell those tips are completely outdated.  There is a
            > clipboard on Mac OS X and MacVim.app uses it properly -- there is no
            > need to use "pbcopy/pbpaste".  I already said this in another post but
            > interaction with the pasteboard is fully supported in both GUI and
            > terminal mode (the latter only if you are using the latest snapshot
            > version).  The "+" and "*" registers are one and the same and by
            > default you can use <D-x>/<D-c>/<D-v> to cut/copy/paste just like in
            > any other Mac app.

            OKi, here we go:

            1. This is on MacVim 7.2 stable 1.2 (33.3)
            2. +clipboard is set when I run :version
            3. Select/yank, select/Cmd-C, select/copy-icon only copy the text
            within
            MacVim -- none of these things make it to the clipboard
            4. Programmatic copy by assigning a value to @+ doesn't copy the
            text to the system clipboard either

            For no. 4, here is the complete code snippet that tries to copy the
            text to the clipboard:

            for line in output
            let nPtr = match(line, s:PASTE_RESPONSE_FLAG)

            if nPtr != -1
            let location = s:ParseLocationFrom(line)
            echomsg location

            if has("gui_running")
            let clipboardContents = split(location, " ")
            let @+ = clipboardContents[0x01]
            endif

            return
            endif
            endfor

            The only case that I care about is (4), because this emerged from a
            script that I wrote with some of the guys in #vim/Freenode and that we
            want to publish this weekend. It'd be awesome if we could report "the
            script was tested and passed across all platforms" or something along
            those lines. We are able to copy to the clipboard with gvim just fine
            across all platforms.

            Here is my .vimrc:
            http://eugeneciurana.com/pastebin/pastebin.php?show=40955

            And my .gvimrc:
            http://eugeneciurana.com/pastebin/pastebin.php?show=40957

            One more thing: gvim copies to the clipboard fine on the same Mac
            where I'm testing this. I can assign @+ = "whatever" and it'll make
            it to the clipboard. So this problem appears to be isolated to MacVim
            only.

            Thanks in advance and have a great weekend,

            pr3d4t0r

            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_mac" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • björn
            ... Are you starting MacVim from Terminal while using GNU screen by any chance? GNU screen breaks the connection to the pasteboard server for some reason so
            Message 5 of 15 , Apr 5, 2009
            • 0 Attachment
              2009/4/5 pr3d4t0r:
              >
              > OKi, here we go:
              >
              > 1. This is on MacVim 7.2 stable 1.2 (33.3)
              > 2. +clipboard is set when I run :version
              > 3. Select/yank, select/Cmd-C, select/copy-icon only copy the text
              > within
              >   MacVim -- none of these things make it to the clipboard
              > 4. Programmatic copy by assigning a value to @+ doesn't copy the
              >   text to the system clipboard either

              Are you starting MacVim from Terminal while using GNU screen by any
              chance? GNU screen breaks the connection to the pasteboard server for
              some reason so any program started from within screen will not have
              clipboard support (this is not a MacVim-specific issue). (If you are
              not using "screen" then perhaps you could try starting MacVim in
              different ways and see if that fixes the problem, e.g. double-click
              icon, use mvim script, etc.)

              Björn

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_mac" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            • pr3d4t0r
              ... OKi, I found a way to recreate this. If MacVim starts from the GUI (Finder or Quicksilver or whatever) then integration with the keyboard works great. If
              Message 6 of 15 , Apr 5, 2009
              • 0 Attachment
                On Apr 5, 7:41 am, pr3d4t0r <ciur...@...> wrote:
                > On Apr 5, 4:43 am, björn <bjorn.winck...@...> wrote:
                >
                > > 2009/4/5 John Beckett:
                > > > pr3d4t0r wrote:
                > > >> :let @+ = "this is a test."
                >
                > > > Does MacVim show '+clipboard' for the :version command?
                >
                > > As far as I can tell those tips are completely outdated.  There is a
                > > clipboard on Mac OS X and MacVim.app uses it properly -- there is no
                > > need to use "pbcopy/pbpaste".  I already said this in another post but
                > > interaction with the pasteboard is fully supported in both GUI and
                > > terminal mode (the latter only if you are using the latest snapshot
                > > version).  The "+" and "*" registers are one and the same and by
                > > default you can use <D-x>/<D-c>/<D-v> to cut/copy/paste just like in
                > > any other Mac app.
                >
                > OKi, here we go:
                >
                > 1. This is on MacVim 7.2 stable 1.2 (33.3)
                > 2. +clipboard is set when I run :version
                > 3. Select/yank, select/Cmd-C, select/copy-icon only copy the text
                > within
                >    MacVim -- none of these things make it to the clipboard
                > 4. Programmatic copy by assigning a value to @+ doesn't copy the
                >    text to the system clipboard either
                >
                > For no. 4, here is the complete code snippet that tries to copy the
                > text to the clipboard:
                >
                >   for line in output
                >     let nPtr = match(line, s:PASTE_RESPONSE_FLAG)
                >
                >     if nPtr != -1
                >       let location = s:ParseLocationFrom(line)
                >       echomsg location
                >
                >       if has("gui_running")
                >         let clipboardContents = split(location, " ")
                >         let @+ = clipboardContents[0x01]
                >       endif
                >
                >       return
                >     endif
                >   endfor
                >
                > The only case that I care about is (4), because this emerged from a
                > script that I wrote with some of the guys in #vim/Freenode and that we
                > want to publish this weekend.  It'd be awesome if we could report "the
                > script was tested and passed across all platforms" or something along
                > those lines.  We are able to copy to the clipboard with gvim just fine
                > across all platforms.
                >
                > Here is my .vimrc:http://eugeneciurana.com/pastebin/pastebin.php?show=40955
                >
                > And my .gvimrc:http://eugeneciurana.com/pastebin/pastebin.php?show=40957
                >
                > One more thing:  gvim copies to the clipboard fine on the same Mac
                > where I'm testing this.  I can assign @+ = "whatever" and it'll make
                > it to the clipboard.  So this problem appears to be isolated to MacVim
                > only.
                >
                > Thanks in advance and have a great weekend,

                OKi, I found a way to recreate this.

                If MacVim starts from the GUI (Finder or Quicksilver or whatever) then
                integration with the keyboard works great.

                If MacVim starts from the command line using /usr/bin/mvim or /usr/
                local/bin/mvim then clipboard support doesn't work.

                Thanks and cheers,

                pr3d4t0r
                --~--~---------~--~----~------------~-------~--~----~
                You received this message from the "vim_mac" maillist.
                For more information, visit http://www.vim.org/maillist.php
                -~----------~----~----~----~------~----~------~--~---
              • pr3d4t0r
                ... I found a workaround that seems to fix this. Modify the mvim script to use: /usr/bin/open /Applications/MacVim.app $* That starts MacVim just fine from
                Message 7 of 15 , Apr 5, 2009
                • 0 Attachment
                  On Apr 5, 7:56 am, pr3d4t0r <ciur...@...> wrote:

                  > OKi, I found a way to recreate this.
                  >
                  > If MacVim starts from the GUI (Finder or Quicksilver or whatever) then
                  > integration with the keyboard works great.
                  >
                  > If MacVim starts from the command line using /usr/bin/mvim or /usr/
                  > local/bin/mvim then clipboard support doesn't work.

                  I found a workaround that seems to fix this. Modify the mvim script
                  to use:

                  /usr/bin/open /Applications/MacVim.app $*

                  That starts MacVim just fine from the command line, with support for
                  the clipboard. It doesn't seem to pick up all the options
                  from .gvimrc like the number of columns or rows that I want to start
                  this at, but otherwise it does the job.

                  I haven't analyzed everything that mvim does yet -- I'll wait for your
                  comments first, then I can patch it and submit it with this fix. Or
                  submit a separate script. Or whatever works.

                  Cheers,

                  pr3d4t0r
                  --~--~---------~--~----~------------~-------~--~----~
                  You received this message from the "vim_mac" maillist.
                  For more information, visit http://www.vim.org/maillist.php
                  -~----------~----~----~----~------~----~------~--~---
                • pr3d4t0r
                  ... Yes, I am using screen along with everything else. See my previous reply (I didn t realize that you d already replied to me). Thanks very much for your
                  Message 8 of 15 , Apr 5, 2009
                  • 0 Attachment
                    On Apr 5, 7:51 am, björn <bjorn.winck...@...> wrote:
                    > Are you starting MacVim from Terminal while using GNU screen by any
                    > chance?  GNU screen breaks the connection to the pasteboard server for
                    > some reason so any program started from within screen will not have
                    > clipboard support (this is not a MacVim-specific issue).  (If you are
                    > not using "screen" then perhaps you could try starting MacVim in
                    > different ways and see if that fixes the problem, e.g. double-click
                    > icon, use mvim script, etc.)

                    Yes, I am using screen along with everything else. See my previous
                    reply (I didn't realize that you'd already replied to me).

                    Thanks very much for your help!

                    E
                    --~--~---------~--~----~------------~-------~--~----~
                    You received this message from the "vim_mac" maillist.
                    For more information, visit http://www.vim.org/maillist.php
                    -~----------~----~----~----~------~----~------~--~---
                  • björn
                    ... I m glad you sorted it out. Unfortunately there does not seem to be a fix for the GNU screen problem. You can use open like you said but then you can no
                    Message 9 of 15 , Apr 5, 2009
                    • 0 Attachment
                      2009/4/5 pr3d4t0r:
                      >
                      > On Apr 5, 7:51 am, björn <bjorn.winck...@...> wrote:
                      >> Are you starting MacVim from Terminal while using GNU screen by any
                      >> chance?  GNU screen breaks the connection to the pasteboard server for
                      >> some reason so any program started from within screen will not have
                      >> clipboard support (this is not a MacVim-specific issue).  (If you are
                      >> not using "screen" then perhaps you could try starting MacVim in
                      >> different ways and see if that fixes the problem, e.g. double-click
                      >> icon, use mvim script, etc.)
                      >
                      > Yes, I am using screen along with everything else.  See my previous
                      > reply (I didn't realize that you'd already replied to me).
                      >
                      > Thanks very much for your help!

                      I'm glad you sorted it out.

                      Unfortunately there does not seem to be a fix for the GNU screen
                      problem. You can use "open" like you said but then you can no longer
                      pass command line parameters (apart from file names) so it is a rather
                      limited solution. I'm still hoping somebody will contact the "screen"
                      developers and have them fix this.

                      Björn

                      --~--~---------~--~----~------------~-------~--~----~
                      You received this message from the "vim_mac" maillist.
                      For more information, visit http://www.vim.org/maillist.php
                      -~----------~----~----~----~------~----~------~--~---
                    • pr3d4t0r
                      ... If there is a bug filed in MacVim that you can point me at so that I can understand how MacVim links to the system clipboard, and then find a workaround.
                      Message 10 of 15 , Apr 5, 2009
                      • 0 Attachment
                        On Apr 5, 8:22 am, björn <bjorn.winck...@...> wrote:
                        > Unfortunately there does not seem to be a fix for the GNU screen
                        > problem.  You can use "open" like you said but then you can no longer
                        > pass command line parameters (apart from file names) so it is a rather
                        > limited solution.  I'm still hoping somebody will contact the "screen"
                        > developers and have them fix this.

                        If there is a bug filed in MacVim that you can point me at so that I
                        can understand how MacVim links to the system clipboard, and then find
                        a workaround. One alternative I was thinking of is having a Python
                        (maybe even C?) plugin that is loaded silently under OS X and
                        communicates with the clipboard that way when running screen.

                        I will also look into patching screen -- I'm not a committer there and
                        have crossed swords with too many GNU guys because we have different
                        views of reality when it comes to licensing so I'm not sure if they'd
                        accept a patch.

                        Thanks and cheers,

                        E
                        --~--~---------~--~----~------------~-------~--~----~
                        You received this message from the "vim_mac" maillist.
                        For more information, visit http://www.vim.org/maillist.php
                        -~----------~----~----~----~------~----~------~--~---
                      • björn
                        ... The problem has been discussed on this list (you ll have to search for it) and there and issue was created:
                        Message 11 of 15 , Apr 5, 2009
                        • 0 Attachment
                          2009/4/5 pr3d4t0r:
                          >
                          > On Apr 5, 8:22 am, björn <bjorn.winck...@...> wrote:
                          >> Unfortunately there does not seem to be a fix for the GNU screen
                          >> problem.  You can use "open" like you said but then you can no longer
                          >> pass command line parameters (apart from file names) so it is a rather
                          >> limited solution.  I'm still hoping somebody will contact the "screen"
                          >> developers and have them fix this.
                          >
                          > If there is a bug filed in MacVim that you can point me at so that I
                          > can understand how MacVim links to the system clipboard, and then find
                          > a workaround.  One alternative I was thinking of is having a Python
                          > (maybe even C?) plugin that is loaded silently under OS X and
                          > communicates with the clipboard that way when running screen.
                          >
                          > I will also look into patching screen -- I'm not a committer there and
                          > have crossed swords with too many GNU guys because we have different
                          > views of reality when it comes to licensing so I'm not sure if they'd
                          > accept a patch.

                          The problem has been discussed on this list (you'll have to search for
                          it) and there and issue was created:

                          http://code.google.com/p/macvim/issues/detail?id=106

                          Basically, there is a process called "pboard" which apps communicate
                          with to implement copy/paste. From within "screen" this process is
                          unreachable (for some unknown reason). I have tried connecting to it
                          using both the Carbon and Cocoa APIs but you always get a NULL pointer
                          when you try to access "pboard" from within "screen".

                          What this means is that unless you know how the Carbon/Cocoa APIs work
                          internally it is going to be hard to fix this problem. You'd have to
                          create some other process that is launched outside "screen" and
                          connect via that process to the pasteboard server. I never even
                          considered trying this because it must be much easier to just patch
                          "screen".

                          Björn

                          --~--~---------~--~----~------------~-------~--~----~
                          You received this message from the "vim_mac" maillist.
                          For more information, visit http://www.vim.org/maillist.php
                          -~----------~----~----~----~------~----~------~--~---
                        • pr3d4t0r
                          Björn and everyone, Thanks for your help in figuring out the clipboard / screen situation. The code is written and working now -- w00t! I just posted
                          Message 12 of 15 , Apr 5, 2009
                          • 0 Attachment
                            Björn and everyone,

                            Thanks for your help in figuring out the clipboard / screen
                            situation. The code is written and working now -- w00t!

                            I just posted paster.vim - a configurable script for posting text to a
                            public pastebin to vim.org and to my site.

                            Take care and have a great weekend,

                            pr3d4t0r
                            http://eugenciurana.com/paster.vim
                            http://www.vim.org/scripts/script.php?script_id=2602

                            --~--~---------~--~----~------------~-------~--~----~
                            You received this message from the "vim_mac" maillist.
                            For more information, visit http://www.vim.org/maillist.php
                            -~----------~----~----~----~------~----~------~--~---
                          • pr3d4t0r
                            Heh -- http://eugeneciurana.com/paster.vim -- :) --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_mac maillist.
                            Message 13 of 15 , Apr 5, 2009
                            • 0 Attachment
                              Heh -- http://eugeneciurana.com/paster.vim -- :)
                              --~--~---------~--~----~------------~-------~--~----~
                              You received this message from the "vim_mac" maillist.
                              For more information, visit http://www.vim.org/maillist.php
                              -~----------~----~----~----~------~----~------~--~---
                            Your message has been successfully submitted and would be delivered to recipients shortly.