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

128877Re: Preventing Double maps/abbs

Expand Messages
  • Jürgen Krämer
    Feb 2, 2012
      Hi,

      howard Schwartz wrote:
      > I recently discovered a pitfall similar to recursive abbreviations or maps (in
      > math logic we would would tend to call them `transitive' instead of recursive).
      >
      > As you know, noremap prevents map a b then map b c thus mapping a to c
      >
      > But a ran into this dilemma: my friend used these abbreviations and maps:
      >
      > ab q can map q i ^[
      > ab gr gramma map g :write^M
      >
      > thus eliminating the gq formatting command. When I tried to restore it, I
      > first tried to unmap q

      it would probably have been better if your friend had used

      iabbrev q can
      iabbrev gr gramma
      nmap q i ^[
      nmap g :write^M

      to define the abbreviations and maps, thus restricting them to the modes
      where they are really needed.

      > I got the error message, ``No such mapping'' even though the maps command
      > clearly listedd q as mapped to write. I quickly learned I had to
      > unabbreviate q before I could unmap q. Similar things applied to the letter g
      > in order to recover he command gq.
      >
      > What seems to happen is an interaction between abbreviations and maps: When I
      > gave the ex command :q <ENTER> upon hitting <ENTER> vim expands q to `can' and
      > then treats `can' as a write command. When I try to unmap q, I press
      > <ENTER>. Thus,
      > q expands to `can' and vim correctly replies ``no such mapping'' meaning
      > there is no direct map of the latters `can' to a write command.

      For me Vim's reply is

      E492: Not an editor command: can

      No remapping took place, but "can" is not a recognized command.

      > Multiple abbreviations or maps of the same letters is not a problem, within
      > maps or ab alone -- ordinarily last definition wins.
      >
      > What seems to be needed is a version of abbreviate that says ``only abbreviate
      > these letters, do not use them to map a command''. The modes for maps and ab
      > do not help, because sometimes one really wants letters expanded on the
      > command line, for example when executing a substitute command.

      There are also [ic]noreabbrev variants which would prevent the
      right-hand-side of an abbreviation to be re-used as the left-hand-side
      of a mapping.

      Regards,
      Jürgen

      --
      Sometimes I think the surest sign that intelligent life exists elsewhere
      in the universe is that none of it has tried to contact us. (Calvin)

      --
      You received this message from the "vim_use" 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 7 messages in this topic