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

129002Re: Preventing Double maps/abbs

Expand Messages
  • Jürgen Krämer
    Feb 13, 2012
    • 0 Attachment
      Hi,

      howardb21 wrote:
      >
      > On Feb 5, 11:35 pm, Jürgen Krämer <jottka...@...> wrote:
      >> Hi,
      >>
      >> howardb21 wrote:
      >>> On Feb 2, 10:26 pm, J rgen Kr mer <jottka...@...> wrote:
      >>
      >>>> 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.
      >>
      >>> Where do I find these variants?
      >
      >> :help :cnoreabbrev
      >> :help :inoreabbrev
      >>
      >> Regards,
      >> J rgen
      >
      > Pardon my ignorance, but the variants of noremap o noeabbrev, simply
      > prevent the
      > the second member of a map/abbreviation from being used as a first
      > member in another map/abrev. OR they restrict a mapping/abrev to one
      > mode only.
      >
      > If I go :inoreabbrev g group
      >
      > this prevents group from being
      > used as an abbreviation, and prevents, `g' from being expanded on the
      > command line.

      yes, the leading "i" and "c" restrict the abbreviation to insert mode
      and command-line mode, respectively. The "nore" part prevents the just
      expanded right-hand-side ("group" in your case) from being immediately
      used as the left-hand-side of a map. E.g., if you had defined

      :iabbrev g group
      :imap group <c-o>:echo "This is my group."<cr>

      and you enter "g" and a space in insert mode, only the space would be
      inserted into the buffer and the text "This is my group." would be
      echoed on the command line.

      > but it does not prevent `g' from being used in Another
      > map or abbreviation anywhere. It g is used for another insert mode
      > abbreviation - not too bad - last definition will win. If it it done
      > in command or normal mode, than g will
      > act differently in insert, normal, command, even visual modes and
      > never, perhaps act as as the original `go' command of normal mode.
      >
      > It still seems, there is no way to map or abrev a character in such a
      > way that this character is prohibited from being mapped or abrev'ed
      > again, unless the original
      > map/abrev is undone.

      There is the <unique> flag for maps and abbreviations (see

      :help :map-<unique>

      ), which prevents you from redefining/overwriting a map or abbreviation,
      though it seems a map can still be overwritten by an abbreviation and
      vice versa.

      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