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

12218Re: Strange copy/paste behavior with newlines

Expand Messages
  • björn
    Mar 31, 2011
      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.


      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
    • Show all 9 messages in this topic