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

Re: abbreviation difficulty

Expand Messages
  • Jürgen Krämer
    Hi, ... there is a little helper function described below :help abbreviation func Eatchar(pat) let c = nr2char(getchar()) return (c =~ a:pat) ? : c
    Message 1 of 10 , Jan 2, 2006
    • 0 Attachment
      Hi,

      jkilbour@... schrieb:
      >
      >> jkilbour@... said the following on 24/12/2005 6:54 AM:
      >>
      >>> I added this to my _vimrc:
      >>> abbr bbb BEGIN{FS="|"}
      >>>
      >>> but something is going on with the quotes and bar; when I type
      >>> "bbb ",
      >>> I get
      >>> BEGIN{FS="
      >>>
      >>> what will help?
      >>>
      >>>
      >>>
      >> Are you expecting the cursor to be at the bar ("|") when the
      >> abbreviation triggers like other windows editors? If so Vim doesn't work
      >> like that. Try:
      >> iab bbb BEGIN{FS=""}<left><left>
      >> hitting the space bar gives BEGIN{FS=" |"}
      >> which probably isn't what you want (extra space).
      >> Hitting Ctl-] gives BEGIN{FS="|"}
      >>
      >> --
      >> Mark
      >
      >
      > This is working almost perfectly:
      > :abbr bbb BEGIN{FS="<Bar>"}
      >
      > However, it puts an extra space at the end.

      there is a little helper function described below ":help abbreviation"

      func Eatchar(pat)
      let c = nr2char(getchar())
      return (c =~ a:pat) ? '' : c
      endfunc

      You can use it to discard the white space that toggled the expansion of
      the abbreviation by calling it through the special register "=

      iabbr <silent> bbb BEGIN{FS="<Bar>"}<C-R>=Eatchar('\s')<CR>

      Regards,
      Jürgen

      --
      Jürgen Krämer Softwareentwicklung
      HABEL GmbH & Co. KG mailto:jkr@...
      Hinteres Öschle 2 Tel: +49 / 74 61 / 93 53 - 15
      78604 Rietheim-Weilheim Fax: +49 / 74 61 / 93 53 - 99
    Your message has been successfully submitted and would be delivered to recipients shortly.