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

Strange copy/paste behavior with newlines

Expand Messages
  • Robin
    Hello all, I m having a bit of a strange issue with copy/paste from external applications on MacVim snapshot 57 on Snow Leopard 10.6.6. Let s say I have a
    Message 1 of 9 , Mar 17 7:41 AM
    • 0 Attachment
      Hello all,

      I'm having a bit of a strange issue with copy/paste from external
      applications on MacVim snapshot 57 on Snow Leopard 10.6.6.

      Let's say I have a piece of text in my MacVim buffer:

      Foo bar.

      If I copy a line of text, place my cursor between "Foo" and "bar" and
      press <D-v>, I get:

      Foo copiedtext bar.

      As expected. However, if I copy several lines of text from some
      external application, then put my cursor between "Foo" and "bar" and
      press <D-v>, I get:

      copied text line 1
      copied text line 2
      Foo bar.

      Instead of the copied text being inserted at the cursor position. This
      only seems to occur with text copied from certain sources. For
      example, a block of text in a website will not exhibit this behavior
      (copied text will be inserted between "foo" and "bar" as expected),
      but text copied from a PDF will. Perhaps it has something to do with
      the way newlines are encoded in the PDF?

      Do any of you know what's going on, and how I can correct it?

      Thanks!
      -Robin

      --
      You received this message from the "vim_mac" 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
    • björn
      ... Vim has a concept of selections over characters/lines/block. When pasting from the OS X Pasteboard MacVim has to guess which of these to use. From your
      Message 2 of 9 , Mar 21 11:29 AM
      • 0 Attachment
        On 17 March 2011 15:41, Robin wrote:
        > Hello all,
        >
        > I'm having a bit of a strange issue with copy/paste from external
        > applications on MacVim snapshot 57 on Snow Leopard 10.6.6.
        >
        > Let's say I have a piece of text in my MacVim buffer:
        >
        > Foo bar.
        >
        > If I copy a line of text, place my cursor between "Foo" and "bar" and
        > press <D-v>, I get:
        >
        > Foo copiedtext bar.
        >
        > As expected. However, if I copy several lines of text from some
        > external application, then put my cursor between "Foo" and "bar" and
        > press <D-v>, I get:
        >
        > copied text line 1
        > copied text line 2
        > Foo bar.
        >
        > Instead of the copied text being inserted at the cursor position. This
        > only seems to occur with text copied from certain sources. For
        > example, a block of text in a website will not exhibit this behavior
        > (copied text will be inserted between "foo" and "bar" as expected),
        > but text copied from a PDF will. Perhaps it has something to do with
        > the way newlines are encoded in the PDF?
        >
        > Do any of you know what's going on, and how I can correct it?

        Vim has a concept of selections over characters/lines/block. When
        pasting from the OS X Pasteboard MacVim has to guess which of these to
        use. From your description this is what is causing the discrepancy.

        Can you give me a simple reproducible case that exhibits unexpected
        behavior. I might be able to fix it.

        Björn

        --
        You received this message from the "vim_mac" 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
      • Frank Hellenkamp
        Hi, ... Is there a way to enforce the pasting as characters . Normally, if I want to paste a few lines, I go into insert mode at the specific point and paste
        Message 3 of 9 , Mar 23 4:17 AM
        • 0 Attachment
          Hi,

          > Vim has a concept of selections over characters/lines/block. When
          > pasting from the OS X Pasteboard MacVim has to guess which of these to
          > use. From your description this is what is causing the discrepancy.
          >
          > Can you give me a simple reproducible case that exhibits unexpected
          > behavior. I might be able to fix it.

          Is there a way to enforce the pasting "as characters".

          Normally, if I want to paste a few lines, I go into insert mode at the
          specific point and paste then.

          E.g.:
          If I have a <p>_</p>, I want to insert in between (where my cursor is)
          on not as whole lines.

          But if there is more than one line in the pasteboard, the pasted text
          will be in a new line just before the "<p></p>".


          Thanks

          Frank

          --
          frank hellenkamp | interface designer
          solmsstraße 7 | 10961 berlin

          +49.30.49 78 20 70 | tel
          +49.176.32 13 88 89 | mbl
          +49.3212.100 35 22 | fax
          jonas@...

          http://depage.net | bureau
          http://depagecms.net | content management
          http://immerdasgleiche.de | read
          http://everydayisexactlythesame.net | see
        • Zsombor Nagy
          ... Hi! I have exactly the same problem. It would be nice to force it always paste as characters! e.g. I start a new line, press two tabs, and then I want to
          Message 4 of 9 , Mar 29 2:05 AM
          • 0 Attachment
            Frank Hellenkamp <jonas.info@...> writes:

            > Is there a way to enforce the pasting "as characters".
            >
            > Normally, if I want to paste a few lines, I go into insert mode at the
            > specific point and paste then.
            >
            > E.g.:
            > If I have a <p>_</p>, I want to insert in between (where my cursor is)
            > on not as whole lines.
            >
            > But if there is more than one line in the pasteboard, the pasted text
            > will be in a new line just before the "<p></p>".
            >
            > Thanks
            >
            > Frank
            >

            Hi!

            I have exactly the same problem.
            It would be nice to force it always paste as characters!

            e.g. I start a new line, press two tabs, and then I want to
            paste the text there, but instead of that, the
            text gets pasted into a new line before my started line.

            Also it would be very good if multiline paste would be
            automatically indented to the same level where I
            stand, e.g. I have this in my pasteboard:

            asdfasdf
            asgasdg
            asdgasdg

            Then I start a new line, and press some spaces and a pipe:

            | <- I'm standing here

            Now I would press cmd-c and it would create this

            |asdfasdf
            asgasdg
            asdgasdg

            Instead of this:

            asdfasdf
            asgasdg
            asdgasdg
            |

            Thanks!

            I just started to use MacVim, and I love it, thanks!

            Cheers,
            Zsombor

            --
            You received this message from the "vim_mac" 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
          • björn
            ... I don t know of any way. ... I also have issues with this behavior. When in insert mode I always want the text where the cursor is. Pasting is set up
            Message 5 of 9 , Mar 29 1:33 PM
            • 0 Attachment
              2011/3/23 Frank Hellenkamp:
              >
              > Is there a way to enforce the pasting "as characters".

              I don't know of any way.

              > Normally, if I want to paste a few lines, I go into insert mode at the
              > specific point and paste then.
              >
              > E.g.:
              > If I have a <p>_</p>, I want to insert in between (where my cursor is)
              > on not as whole lines.
              >
              > But if there is more than one line in the pasteboard, the pasted text
              > will be in a new line just before the "<p></p>".

              I also have issues with this behavior. When in insert mode I always
              want the text where the cursor is.

              Pasting is set up inside $VIMRUNTIME/menu.vim which calls a function
              inside $VIMRUNTIME/autoload/paste.vim. Have a look at that and see if
              you can figure something out (I'm too tired to make sense of this
              stuff right now). Failing that, try asking on vim_use.

              Björn

              --
              You received this message from the "vim_mac" 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
            • Tyson Roberts
              I could be misinterpreting what you want, but does this do what you want? nn p ai ... -- You received this message from the vim_mac
              Message 6 of 9 , Mar 29 8:40 PM
              • 0 Attachment
                I could be misinterpreting what you want, but does this do what you want?

                nn <leader>p ai<C-R>"<ESC>


                On Tue, Mar 29, 2011 at 6:05 PM, Zsombor Nagy <zsombor42@...> wrote:
                Frank Hellenkamp <jonas.info@...> writes:

                > Is there a way to enforce the pasting "as characters".
                >
                > Normally, if I want to paste a few lines, I go into insert mode at the
                > specific point and paste then.
                >
                > E.g.:
                > If I have a <p>_</p>, I want to insert in between (where my cursor is)
                > on not as whole lines.
                >
                > But if there is more than one line in the pasteboard, the pasted text
                > will be in a new line just before the "<p></p>".
                >
                > Thanks
                >
                > Frank
                >

                Hi!

                I have exactly the same problem.
                It would be nice to force it always paste as characters!

                e.g. I start a new line, press two tabs, and then I want to
                paste the text there, but instead of that, the
                text gets pasted into a new line before my started line.

                Also it would be very good if multiline paste would be
                automatically indented to the same level where I
                stand, e.g. I have this in my pasteboard:

                asdfasdf
                asgasdg
                asdgasdg

                Then I start a new line, and press some spaces and a pipe:

                    | <- I'm standing here

                Now I would press cmd-c and it would create this

                   |asdfasdf
                   asgasdg
                   asdgasdg

                Instead of this:

                asdfasdf
                asgasdg
                asdgasdg
                   |

                Thanks!

                I just started to use MacVim, and I love it, thanks!

                Cheers,
                Zsombor

                --
                You received this message from the "vim_mac" 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 from the "vim_mac" 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
              • björn
                ... I think there is a typo in here, but it is the right idea. In insert mode, instead of using Cmd-v, try + If the text on the pasteboard is linewise
                Message 7 of 9 , Mar 30 11:34 AM
                • 0 Attachment
                  On 30 March 2011 05:40, Tyson Roberts wrote:
                  > I could be misinterpreting what you want, but does this do what you want?
                  >
                  > nn <leader>p ai<C-R>"<ESC>

                  I think there is a typo in here, but it is the right idea. In insert
                  mode, instead of using Cmd-v, try

                  <C-R>+

                  If the text on the pasteboard is linewise there will be an extra
                  newline at the end of the pasted text, but hitting hitting delete will
                  take care of that.

                  This can be used together with :imenu to change the behavior of Cmd-v.
                  I'll leave that as an exercise (sorry).

                  Björn

                  --
                  You received this message from the "vim_mac" 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
                • Zsombor Nagy
                  ... Hi all! I m experiencing something unexpected. I tried to make Cmd-v doing this + stuff, but first I only added this to my .gvimrc: macmenu
                  Message 8 of 9 , Mar 30 3:46 PM
                  • 0 Attachment
                    This can be used together with :imenu to change the behavior of Cmd-v.
                     I'll leave that as an exercise (sorry).

                    Hi all!

                    I'm experiencing something unexpected. I tried to make Cmd-v doing this <C-R>+ stuff, but first I only added this to my .gvimrc:

                    macmenu &Edit.Paste key=<nop>

                    And then I expected Cmd-v not doing anything. First I checked in the Edit menu, and yes the shortcut disappeared. Then I pressed Cmd-v, and it... pasted!

                    And it also behaves interestingly, because in normal mode it behaves as I explained before, so wherever my cursor is, it pushes the line down, and paste the multiline text there. But in insert mode, it actually does that "character-paste" stuff!

                    So I have this in my clipboard:

                    aaa
                    bbb
                    ccc

                    I type "hello" then I press cmd-v, and this happens:

                    hello aaa
                    bbb
                    ccc

                    I type hello goodbye, put the cursor between the words and press cmd-v:

                    hello aaa
                    bbb
                    ccc
                    goodbye

                    if I do the same in normal mode:

                    aaa
                    bbb
                    ccc
                    hello goodbye



                    So, anybody knows what do I experience here?

                    Thanks!

                    Cheers,
                    Zsombor

                    --
                    You received this message from the "vim_mac" 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
                  • björn
                    ... This sounded weird so I had to take a closer look. It turns out that some keyboard bindings are hardwired in the source code for Mac OS X (this is a
                    Message 9 of 9 , Mar 31 1:06 PM
                    • 0 Attachment
                      On 31 March 2011 00:46, Zsombor Nagy wrote:
                      >> This can be used together with :imenu to change the behavior of Cmd-v.
                      >>  I'll leave that as an exercise (sorry).
                      >
                      > Hi all!
                      > I'm experiencing something unexpected. I tried to make Cmd-v doing this
                      > <C-R>+ stuff, but first I only added this to my .gvimrc:
                      > macmenu &Edit.Paste key=<nop>
                      > And then I expected Cmd-v not doing anything. First I checked in the Edit
                      > menu, and yes the shortcut disappeared. Then I pressed Cmd-v, and it...
                      > pasted!
                      > And it also behaves interestingly, because in normal mode it behaves as I
                      > explained before, so wherever my cursor is, it pushes the line down, and
                      > paste the multiline text there. But in insert mode, it actually does that
                      > "character-paste" stuff!
                      > So I have this in my clipboard:
                      > aaa
                      > bbb
                      > ccc
                      > I type "hello" then I press cmd-v, and this happens:
                      > hello aaa
                      > bbb
                      > ccc
                      > I type hello goodbye, put the cursor between the words and press cmd-v:
                      > hello aaa
                      > bbb
                      > ccc
                      > goodbye
                      > if I do the same in normal mode:
                      > aaa
                      > bbb
                      > ccc
                      > hello goodbye
                      >
                      >
                      > So, anybody knows what do I experience here?

                      This sounded weird so I had to take a closer look. It turns out that
                      some keyboard bindings are hardwired in the source code for Mac OS X
                      (this is a leftover, I did not add it). In particular, it binds <D-v>
                      to <C-R>* (which is the same as <C-R>+ as I suggested earlier).

                      You might be tempted to leave the menu unbound but do note that paste
                      will not work in dialog boxes anymore if you do that.

                      I'm putting it on my todo list to make <D-v> do something like <C-R>+
                      in insert mode by default. It should be as simple as

                      :inoremenu Edit.Paste <C-R>+

                      but I will take a closer look (e.g. what happens with pasting a block
                      selection, etc.). Also, I need to see how other GUIs behave.

                      Björn

                      --
                      You received this message from the "vim_mac" 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
                    Your message has been successfully submitted and would be delivered to recipients shortly.