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

Re: new to VIM

Expand Messages
  • Antony Scriven
    ... That s quite easy: imap and define your abbrevs like so: ab foo foobarbaraann() Then foo will expand to foobarbaraann() but
    Message 1 of 12 , Dec 31, 2008
    • 0 Attachment
      2008/12/29 Ben Schmidt <mail_ben_schmidt@...>:

      > I don't know of any way to turn off abbreviation
      > expansion when you use space or enter, though.

      That's quite easy:

      imap <c-b> <c-v><c-a><c-]>

      and define your abbrevs like so:

      ab foo<c-a> foobarbaraann()

      Then foo<c-b> will expand to foobarbaraann() but foo<space>
      will not. Obviously foo<c-v><c-a><space> will also expand to
      foobarbaraann(), but you're not going type that. Are you? --Antony

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Antony Scriven
      2008/12/31 pansz :³ÌÁº дµÀ: Thanks a lot for your help. What I want to get is that, turn off space or enter for
      Message 2 of 12 , Dec 31, 2008
      • 0 Attachment
        2008/12/31 pansz <panshizhu@...>:

        > 程梁 写道:
        > > Thanks a lot for your help. What I want to get is that,
        > > turn off space or enter for expanding abbreviations and
        > > make other keys such as Ctrl+B do the same thing.
        > > Because I maybe define a lot abbreviations and I cannot
        > > map so much keys to an abbreviation. But thank you all
        > > the same.
        > >
        > > [...]
        > > What you need is a mapping, not abbr, see :help map for
        > > that.
        > >
        > > for example:
        > >
        > > :imap <C-B> for (i=0; i<; i++) {<esc>7hi
        > >
        > > Would map something you like to Ctrl+B, Try and see.
        >
        > I wonder whether you have tried my example or not, does
        > it work for you? Why you insist doing an abbreviation
        > while mapping suits your need a lot better? [...]

        Mappings are short key sequences. What happens when you have
        lots of :abbrevs? You need longer names so that you can
        remember them easily. Long key sequences for mappings are
        unwieldy: you can't see what you are typing and they time
        out. You can backspace and correct a typo in an :abbrev and
        it will still work. --Antony

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Tony Mechelynck
        ... [...] ... With showcmd on, you see what you are typing for a multikey mapping at the bottom right of the screen. For the {lhs} of a mapping, you would
        Message 3 of 12 , Dec 31, 2008
        • 0 Attachment
          On 31/12/08 11:14, Antony Scriven wrote:
          > 2008/12/31 pansz<panshizhu@...>:
          [...]
          > > I wonder whether you have tried my example or not, does
          > > it work for you? Why you insist doing an abbreviation
          > > while mapping suits your need a lot better? [...]
          >
          > Mappings are short key sequences. What happens when you have
          > lots of :abbrevs? You need longer names so that you can
          > remember them easily. Long key sequences for mappings are
          > unwieldy: you can't see what you are typing and they time
          > out. You can backspace and correct a typo in an :abbrev and
          > it will still work. --Antony

          With 'showcmd' on, you see what you are typing for a multikey mapping at
          the bottom right of the screen.

          For the {lhs} of a mapping, you would typically use an F key (except F1
          which is Help and, on some systems, F10 which is Menu), with or without
          shift (including Shift-F1 and Shift-F10). That's already 22 keys. If you
          have more mappings than that, you can use an F key as a prefix for one
          or two additional keys (where any key can be used, probably a printing
          key: that's 26 lowercase, 26 uppercase, 10 digits, and more). How many
          mappings have you got?

          OTOH, for an abbrev you would typically use, well, an abbreviated word.
          Maybe BBC for British Broadcasting Corporation. Or, for a more
          Vim-realistic example, I have ":cabbrev h bot h" in my vimrc, so a new
          help window always opens at the bottom, even when called from a
          split-window which is not the lowest one. Here, a non-id character quite
          logically causes the abbrev to be expanded, while the same letter
          sequence as part of a longer word would, again quite logically, not
          trigger the expansion. When, for instance, I use ":hardcopy" it doesn't
          get the ":bot" prefix.


          Best regards,
          Tony.
          --
          The Third Law of Photography:
          If you did manage to get any good shots, they will be ruined
          when someone inadvertently opens the darkroom door and all of the dark
          leaks out.

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Antony Scriven
          On Wed, Dec 31, 2008 at 12:27 PM, Tony Mechelynck ... ... until you make a typo or the mapping times out. --Antony
          Message 4 of 12 , Dec 31, 2008
          • 0 Attachment
            On Wed, Dec 31, 2008 at 12:27 PM, Tony Mechelynck
            <antoine.mechelynck@...> wrote:

            > On 31/12/08 11:14, Antony Scriven wrote:
            > > [...]
            > >
            > > Mappings are short key sequences. What happens when you have
            > > lots of :abbrevs? You need longer names so that you can
            > > remember them easily. Long key sequences for mappings are
            > > unwieldy: you can't see what you are typing and they time
            > > out. You can backspace and correct a typo in an :abbrev and
            > > it will still work. --Antony
            >
            > With 'showcmd' on, you see what you are typing for
            > a multikey mapping at the bottom right of the screen.

            ... until you make a typo or the mapping times out. --Antony

            --~--~---------~--~----~------------~-------~--~----~
            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.