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

63800Re: pastetoggle

Expand Messages
  • Gerald Lai
    Dec 2, 2005
      On Thu, 1 Dec 2005, Harry Putnam wrote:

      > Chris Allen <c.d.allen@...> writes:
      >
      >> On 01/12/05, Harry Putnam <reader@...> wrote:
      >>> You are speaking of gvim here right? But I don't normally use gvim.
      >>> I prefer plain vim from too much work in console mode.
      [snip]
      > Here no pasting occurs. Only a screen flash like a visual bell type
      > flash.
      >
      > The help manual says C-R C-O * <ENTER> is supposed to be the same as
      > pasting with middlemouse, but here that is not the case. It pastes
      > nothing for me, whereas middle mouse pastes the clipboard text but has
      > the stepping problem.

      Harry,

      I seem to have the same problem as you, and I think I managed to track it down
      to the 'mouse' setting. Apparently, middleclick pasting does not work if
      'mouse=a'. Doing ':set mouse=' will make middleclick pasting work again, but
      we'll lose many mouse funtionalities in console Vim.

      The mapping Chip Campbell provided

      noremap <MiddleMouse> ...<MiddleMouse>...

      will only work if 'mouse' either has the 'a' or 'n' setting. It's a chicken and
      egg problem with the keymap because in order to get middleclick pasting to
      work, we have to get rid of 'a' by ':set mouse-=a', but after getting rid of a,
      we can't do a <MiddleClick> in the keymap.

      The best way I found to balance functionalities is to do the following:

      if has("gui_running")
      set mouse=ra
      else
      set mouse=rn
      nnoremap <MiddleMouse> a<MiddleMouse>
      endif

      This way, whenever a middleclick paste is issued in normal mode, it switches to
      insert mode to do the paste (which would work because it is an 'n' setting).
      While in insert mode, mouse functionality is limited, but that's the sacrifice
      we make. Note that appending "<Esc>" to the end of the nnoremap will kill the
      keymap for some reason.

      Hope this helps.

      -Gerald
    • Show all 25 messages in this topic