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

onoremap with :set insertmode

Expand Messages
  • Georg Dahn
    Hi! I have seen a surprising (to me) behavior of Vim today: 1. Define the mapping onoremap n 2. and do ... You are in Insertmode now 3. Do 4.
    Message 1 of 2 , Apr 3, 2006
    • 0 Attachment
      Hi!

      I have seen a surprising (to me) behavior of Vim
      today:

      1. Define the mapping

      onoremap <F3> <C-C>n

      2. and do

      :set insertmode

      You are in Insertmode now

      3. Do <C-O>
      4. Do d

      You are in Operator pending mode now

      5. Do <F3>

      The result: not the next pattern is searched for, but
      'n' is inserted. I consider, that <C-C> of the mapping
      switches back to Insert mode.

      Is this the normal behavior or shouldn't Vim return to
      Insert mode not before the mapping has finished? If
      'insertmode' is not set, this is the actual behavior
      of Vim when doing the same thing.

      Best wishes,
      Georg









      ___________________________________________________________
      Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com
    • Bram Moolenaar
      ... Well, the CTRL-C aborts the current command. When insertmode is set Vim goes back to Insert mode. I can t say this is wrong. Setting insertmode
      Message 2 of 2 , Apr 3, 2006
      • 0 Attachment
        Georg Dahn wrote:

        > I have seen a surprising (to me) behavior of Vim
        > today:
        >
        > 1. Define the mapping
        >
        > onoremap <F3> <C-C>n
        >
        > 2. and do
        >
        > :set insertmode
        >
        > You are in Insertmode now
        >
        > 3. Do <C-O>
        > 4. Do d
        >
        > You are in Operator pending mode now
        >
        > 5. Do <F3>
        >
        > The result: not the next pattern is searched for, but
        > 'n' is inserted. I consider, that <C-C> of the mapping
        > switches back to Insert mode.
        >
        > Is this the normal behavior or shouldn't Vim return to
        > Insert mode not before the mapping has finished? If
        > 'insertmode' is not set, this is the actual behavior
        > of Vim when doing the same thing.

        Well, the CTRL-C aborts the current command. When 'insertmode' is set
        Vim goes back to Insert mode. I can't say this is wrong. Setting
        'insertmode' changes a lot of things.

        Perhaps what should happen is that CTRL-C should forget about the rest
        of the mapping. But that would break existing mappings, thus we can't
        do that.

        --
        CART DRIVER: Bring out your dead!
        LARGE MAN: Here's one!
        CART DRIVER: Ninepence.
        BODY: I'm not dead!
        "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ download, build and distribute -- http://www.A-A-P.org ///
        \\\ help me help AIDS victims -- http://www.ICCF.nl ///
      Your message has been successfully submitted and would be delivered to recipients shortly.