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

set insertmode in autocommand-events

Expand Messages
  • Nagger
    Hello... Normally I m using vim in insertmode . But in some special buffers I want to turn it off. Since insertmode is a global setting, one cannot use
    Message 1 of 2 , Sep 9, 2003
    • 0 Attachment
      Hello...

      Normally I'm using vim in 'insertmode'.
      But in some special buffers I want to turn it off. Since 'insertmode'
      is a global setting, one cannot use ':setlocal noinsertmode'.

      So I installed two autocommands:

      :au BufEnter [SpecialBuffer] set noinsertmode
      :au BufLeave [SpecialBuffer] set insertmode

      This works for one open window.
      But if there are two open windows (one shows the [SpecialBuffer]) and
      I'm switching the active window it does not work correctly:
      - the autocommand is executed
      - the insertmode is switched correctly
      - BUT: the current mode ('normal' or 'insert') stays at the same mode
      as it was before the window change.

      After every window change I have to press <ESC> to get to the
      right mode.


      As stated, this auto mode-change ('normal' <-> 'insert') works on
      standard ":set [no]insertmode" command and also with the ":buffer"
      commands (with installed :au), but NOT on <CTRL>-W commands or active-
      window-changing mouseclicks.


      Is this a bug? Is there a workaround?
      (I hope at least someone understands my description of this issue.)


      How can I change the current mode within a autocommand-event:

      :au BufEnter [SpecialBuffer] set noinsertmode | normal <ESC>
      does not work either!

      BTW: I'm using Linux gvim.

      Thanx...
      Nagger
    • Bram Moolenaar
      ... I would call it a bug. I ll fix it. -- Arthur pulls Pin out. The MONK blesses the grenade as ... ARTHUR: (quietly) One, two, five ... GALAHAD: Three,
      Message 2 of 2 , Sep 10, 2003
      • 0 Attachment
        Nagger wrote:

        > Normally I'm using vim in 'insertmode'.
        > But in some special buffers I want to turn it off. Since 'insertmode'
        > is a global setting, one cannot use ':setlocal noinsertmode'.
        >
        > So I installed two autocommands:
        >
        > :au BufEnter [SpecialBuffer] set noinsertmode
        > :au BufLeave [SpecialBuffer] set insertmode
        >
        > This works for one open window.
        > But if there are two open windows (one shows the [SpecialBuffer]) and
        > I'm switching the active window it does not work correctly:
        > - the autocommand is executed
        > - the insertmode is switched correctly
        > - BUT: the current mode ('normal' or 'insert') stays at the same mode
        > as it was before the window change.
        >
        > After every window change I have to press <ESC> to get to the
        > right mode.

        You can fix it for now with:

        :au BufEnter [SpecialBuffer] set noinsertmode | stopinsert
        :au BufLeave [SpecialBuffer] set insertmode | startinsert

        > As stated, this auto mode-change ('normal' <-> 'insert') works on
        > standard ":set [no]insertmode" command and also with the ":buffer"
        > commands (with installed :au), but NOT on <CTRL>-W commands or active-
        > window-changing mouseclicks.
        >
        >
        > Is this a bug? Is there a workaround?

        I would call it a bug. I'll fix it.

        --
        Arthur pulls Pin out. The MONK blesses the grenade as ...
        ARTHUR: (quietly) One, two, five ...
        GALAHAD: Three, sir!
        ARTHUR: Three.
        "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
        \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
        \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///
      Your message has been successfully submitted and would be delivered to recipients shortly.