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

Copy after vim line folding loses newlines

Expand Messages
  • J. Lewis Muir
    Using Vim in a Terminal window, when I perform line folding on a text file containing long lines, then select and copy the text (i.e. use a normal Mac OS X
    Message 1 of 3 , Jul 16, 2010
    • 0 Attachment
      Using Vim in a Terminal window, when I perform line folding on a text
      file containing long lines, then select and copy the text (i.e. use a
      normal Mac OS X mouse drag selection followed by Command-C), some
      newlines are lost in the copy! Is there a way to fix this?

      I created a short 24 second screen video showing this behavior at

      http://www.imca.aps.anl.gov/~jlmuir/tmp/vim-terminal.mov

      Here's how to reproduce the problem:

      1. Edit the attached genesis-kjv.txt with Vim (/usr/bin/vim) in a
      Terminal window

      2. Fold the lines to be no longer than 70 characters by typing the
      following commands (<return> means press the Return key):

      :set tw=70<return>
      V
      G
      gq

      3. Select with the mouse the two paragraphs starting at the top left and
      dragging to the end of the last sentence of the second paragraph

      4. Press Command-C to copy the text

      5. Open a second Terminal window (Command-N) and start a new Vim session

      6. In Vim in this second Terminal window, enter Insert mode by typing
      the following command:

      i

      7. In this second Terminal window, press Command-V to paste the copied
      text

      Expected Result:

      I expected to see what I copied (thirteen lines making up the two
      paragraphs with a blank line in between) pasted into the second Terminal
      window.

      Actual Result:

      I get four lines with many of the newlines having been lost. The
      attached genesis-kjv-result.txt shows this.

      Environment:

      I'm running Mac OS X 10.5.8 (Intel) and Vim 7.2.108 (which comes with
      Mac OS X at /usr/bin/vim).

      Other comments:

      I tried this with Vim 7.2.444 installed via MacPorts and had the same
      problem. I tried this with iTerm 0.10 and had the same problem. I
      tried this with MacVim <http://code.google.com/p/macvim/> 7.2 stable 1.2
      and it worked fine.

      Thanks!

      Lewis

      --
      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
      ... A patch to (properly) support copy&paste in console Vim on OS X was merged with the 7.3 branch only days ago. You can download and build from source
      Message 2 of 3 , Jul 17, 2010
      • 0 Attachment
        On 16 July 2010 21:56, J. Lewis Muir wrote:
        > Using Vim in a Terminal window, when I perform line folding on a text
        > file containing long lines, then select and copy the text (i.e. use a
        > normal Mac OS X mouse drag selection followed by Command-C), some
        > newlines are lost in the copy!  Is there a way to fix this?
        >
        > I created a short 24 second screen video showing this behavior at
        >
        >  http://www.imca.aps.anl.gov/~jlmuir/tmp/vim-terminal.mov
        >
        > Here's how to reproduce the problem:
        >
        > 1. Edit the attached genesis-kjv.txt with Vim (/usr/bin/vim) in a
        >   Terminal window
        >
        > 2. Fold the lines to be no longer than 70 characters by typing the
        >   following commands (<return> means press the Return key):
        >
        >   :set tw=70<return>
        >   V
        >   G
        >   gq
        >
        > 3. Select with the mouse the two paragraphs starting at the top left and
        >   dragging to the end of the last sentence of the second paragraph
        >
        > 4. Press Command-C to copy the text
        >
        > 5. Open a second Terminal window (Command-N) and start a new Vim session
        >
        > 6. In Vim in this second Terminal window, enter Insert mode by typing
        >   the following command:
        >
        >   i
        >
        > 7. In this second Terminal window, press Command-V to paste the copied
        >   text
        >
        > Expected Result:
        >
        > I expected to see what I copied (thirteen lines making up the two
        > paragraphs with a blank line in between) pasted into the second Terminal
        > window.
        >
        > Actual Result:
        >
        > I get four lines with many of the newlines having been lost.  The
        > attached genesis-kjv-result.txt shows this.
        >
        > Environment:
        >
        > I'm running Mac OS X 10.5.8 (Intel) and Vim 7.2.108 (which comes with
        > Mac OS X at /usr/bin/vim).
        >
        > Other comments:
        >
        > I tried this with Vim 7.2.444 installed via MacPorts and had the same
        > problem.  I tried this with iTerm 0.10 and had the same problem.  I
        > tried this with MacVim <http://code.google.com/p/macvim/> 7.2 stable 1.2
        > and it worked fine.

        A patch to (properly) support copy&paste in console Vim on OS X was
        merged with the 7.3 branch only days ago. You can download and build
        from source (using hg [1] or git [2]) or wait for 7.3 to be released.
        (When you try it out, note that you have to use "*y and "*p to
        copy&paste.)

        Björn


        [1] http://www.vim.org/mercurial.php
        [2] http://wiki.github.com/b4winckler/vim/

        --
        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
      • J. Lewis Muir
        ... Hi, Björn. I tried the 7.3b BETA branch you suggested and it worked. Excellent! Thanks! Too bad the standard Mac OS X text selection doesn t work. FYI,
        Message 3 of 3 , Jul 20, 2010
        • 0 Attachment
          On 7/17/10 12:16 PM, björn wrote:
          > A patch to (properly) support copy&paste in console Vim on OS X was
          > merged with the 7.3 branch only days ago. You can download and build
          > from source (using hg [1] or git [2]) or wait for 7.3 to be released.
          > (When you try it out, note that you have to use "*y and "*p to
          > copy&paste.)

          Hi, Björn.

          I tried the 7.3b BETA branch you suggested and it worked. Excellent!
          Thanks!

          Too bad the standard Mac OS X text selection doesn't work. FYI, I tried
          the same thing with Emacs 22.1.1 (/usr/bin/emacs) and the standard Mac
          OS X text selection *does* work with it. From a Terminal command prompt
          I typed "emacs genesis-kjv.txt", then:

          C-u 70 C-x f
          C-x h
          M-x fill-region <return>

          (Don't type any spaces. 'C-' means hold down the Control key while
          pressing the key that follows. 'M-' means hold down the Meta key while
          pressing the key that follows. (In my Mac OS X environment, and
          probably the default on most others, I had to press the Escape key and
          let go to generate an 'M-'.) <return> means press the Return key.)

          After doing the above in Emacs, I selected the text using the standard
          Mac OS X click-and-drag method, pressed Command-C, and successfully
          pasted it into a Vim session in insert mode with Command-V.

          It would be great if this could "just work" in Vim as I would expect,
          but I would understand if there's an implementation reason why not.

          Nonetheless, I'm quite pleased with the new yank-to-clipboard feature
          for Mac OS X in Vim 7.3b BETA; it works well for me.

          Thanks!

          Lewis

          --
          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.