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

31990Re: keymaps and Select mode

Expand Messages
  • Bram Moolenaar
    Apr 6 3:54 AM
    • 0 Attachment
      Benji Fisher wrote:

      > > The problem here is that Vim doesn't know that the character you are
      > > typing is going to be inserted. If it was a cursor movement command,
      > > language mappings do not apply to it.
      > >
      > > I can fix it to make the character mapped, but that means it will also
      > > be mapped when it results from a ":noremap" command. Do we care about
      > > this? It's not very likely that a ":noremap"'ed sequence starts Select
      > > mode and inserts a character that should not be lmapped, is it? At
      > > least it's more of a problem that the first inserted character isn't
      > > keymapped.
      > [patch snipped]
      >
      > Sorry to take so long. I just tried the patch. It seems that not only
      > :lmap's get applied but also :imaps. Hm. After
      >
      > :imap r foo
      >
      > typing "r" in Select mode replaces the selection with "foo".

      Yes, the patch makes the first typed character be mapped as if it was
      typed in Insert mode. That's consistent, the second character typed
      will be handled the same way.

      > If, in addition, I do
      >
      > :vmap r R
      >
      > then typing "r" deletes the whole selection. It looks as though the
      > :vmap makes vim switch from Select mode into Visual mode before
      > applying the R.

      Visual mode mappings apply in Select mode as if it were Visual mode.
      Thus that's correct, even though it might not do what you want. I don't
      think this has anything to do with the patch though.

      > I think this patch does way more than advertised. Maybe it is time to
      > promote Select mode to full status, instead of keeping it as a sub-mode of
      > Visual, and give it its own :smap's? (Probably not.) Anyway, Select
      > mode is currently broken as far as keymaps (or :lmaps) are concerned,
      > so I think it is worth trying again.

      I don't see a big disadvantage of this change, and it does make
      keymapping work for the first typed character in Select mode.

      --
      There are three kinds of people: Those who can count & those who can't.

      /// 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 at Amazon -- http://ICCF.nl/click1.html ///
    • Show all 10 messages in this topic