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

Re: Abbreviations Tips

Expand Messages
  • Hari Krishna Dara
    ... You should also know about Bram s popular suggested Eat Char solution that allows you to use as usual for expanding the abbreviation and still
    Message 1 of 10 , Oct 1, 2007
    • 0 Attachment
      On Mon, 1 Oct 2007 at 2:12am, BartlebyScrivener wrote:

      >
      >> It also happens to put a space in the parens when
      >> expanded, so I stumbled across
      >>
      >> :iab f long_function_name()<left><c-o>
      >
      > Hey, that's great. That extra space has bugged me for a year or so. I
      > make headings with H="blah blah" and had
      > iab hh H=""<Left> for an abbreviation.
      >
      > Where did you stumble across that solution?

      You should also know about Bram's popular suggested "Eat Char" solution
      that allows you to use <Space> as usual for expanding the abbreviation
      and still ignore it from getting inserted into the expansion. Here is
      the solution that I use (change the argument to ' ' instead of '\s' to
      make it more restrictive):

      " Eats character if it matches the given pattern.
      "
      " Originally,
      " From: Benji Fisher <fisherbb@...>
      " Date: Mon, 25 Mar 2002 15:05:14 -0500
      "
      " Based on Bram's idea of eating a character while type <Space> to expand an
      " abbreviation. This solves the problem with abbreviations, where we are
      " left with an extra space after the expansion.
      " Ex:
      " inoreabbr \stdout\ System.out.println("");<Left><Left><Left><C-R>=EatChar('\s')<CR>
      function! EatChar(pat)
      let c = nr2char(getchar())
      return (c =~ a:pat) ? '' : c
      endfun

      --
      HTH,
      Hari

      >
      > rd
      >
      >
      > >
      >

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.