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

Abbreviations beginning with non-keyword character

Expand Messages
  • Jonas
    Hi there I wonder if there is really no way to make abbreviations beginning with non-keyword characters. Specifically I want to abbreviate LateX commands, so I
    Message 1 of 4 , Jul 31, 2007
    • 0 Attachment
      Hi there

      I wonder if there is really no way to make abbreviations beginning
      with non-keyword characters.

      Specifically I want to abbreviate LateX commands, so I require them to
      begin with a \ (the abbreviations are still LateX commands in my
      mind).
      Using mapping is inefficient for two reasons: I cannot see what I type
      in the body of the text, and the mapping is triggered as soon as it is
      finished, so that it's very cumbersome to type a non-mapped command
      with the same beginning as a mapped one.

      Thanks for the help.
      Jonas


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Tony Mechelynck
      ... Abbreviations may begin with a non-id character, but there are more constraints: - An end-id abbreviation consists of non-keyword characters followed by
      Message 2 of 4 , Aug 1, 2007
      • 0 Attachment
        Jonas wrote:
        > Hi there
        >
        > I wonder if there is really no way to make abbreviations beginning
        > with non-keyword characters.
        >
        > Specifically I want to abbreviate LateX commands, so I require them to
        > begin with a \ (the abbreviations are still LateX commands in my
        > mind).
        > Using mapping is inefficient for two reasons: I cannot see what I type
        > in the body of the text, and the mapping is triggered as soon as it is
        > finished, so that it's very cumbersome to type a non-mapped command
        > with the same beginning as a mapped one.
        >
        > Thanks for the help.
        > Jonas

        Abbreviations may begin with a non-id character, but there are more constraints:


        - An "end-id" abbreviation consists of non-keyword characters followed by
        exactly one keyword character. It must be preceded by a keyword character, a
        whitespace character, or be at the start of the line or of the insertion.

        - A "non-id" abbreviation consists only of non-keyword characters. It must be
        preceded by whitespace, or be at the start of the line or of the insertion.

        - Any abbreviation whatsoever must be followed by a non-keyword character, or
        by the <Ctrl-]> which triggers expansion, the <Esc> which ends insertion or
        the <Enter> which ends an ex-command.


        What you can do is map the \ key to start a function which would get keyboard
        input, process it, and finally return a string to be inserted into the buffer.
        The partial sequence would probably not appear in the file window though. It
        might be possible (I'm not sure, I haven't pushed the idea to its end) to have
        it appear at the bottom, on the command/status line. I think Dr.Chip is more
        expert than I am about "crazy" mappings.


        Best regards,
        Tony.
        --
        Fresco's Discovery:
        If you knew what you were doing you'd probably be bored.

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • Kahn jonas
        ... That I knew. I wondered if I could have something like al as an abbreviation ... Thank you. I ll try to write a function that does the work. Maybe with
        Message 3 of 4 , Aug 1, 2007
        • 0 Attachment
          Abbreviations may begin with a non-id character, but there are more constraints: [...]

          That I knew. I wondered if I could have something like \al as an abbreviation



          What you can do is map the \ key to start a function which would get keyboard
          input, process it, and finally return a string to be inserted into the buffer.
          The partial sequence would probably not appear in the file window though. It
          might be possible (I'm not sure, I haven't pushed the idea to its end) to have
          it appear at the bottom, on the command/status line. I think Dr.Chip is more
          expert than I am about "crazy" mappings.


          Thank you. I'll try to write a function that does the work. Maybe with python, I can even manage to see it on the screen. I'll let poeple know if I can get a solution (probably an unreadable hack)...

          Jonas


          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---

        • Tony Mechelynck
          ... Don t forget the possibilities of :imap {lhs} {rhs} and :imap {lhs} ={expression} . Best regards, Tony. -- The best thing for being sad,
          Message 4 of 4 , Aug 1, 2007
          • 0 Attachment
            Kahn jonas wrote:
            >
            > Abbreviations may begin with a non-id character, but there are more
            > constraints: [...]
            >
            >
            > That I knew. I wondered if I could have something like \al as an
            > abbreviation
            >
            >
            >
            > What you can do is map the \ key to start a function which would get
            > keyboard
            > input, process it, and finally return a string to be inserted into
            > the buffer.
            > The partial sequence would probably not appear in the file window
            > though. It
            > might be possible (I'm not sure, I haven't pushed the idea to its
            > end) to have
            > it appear at the bottom, on the command/status line. I think Dr.Chip
            > is more
            > expert than I am about "crazy" mappings.
            >
            >
            >
            > Thank you. I'll try to write a function that does the work. Maybe with
            > python, I can even manage to see it on the screen. I'll let poeple know
            > if I can get a solution (probably an unreadable hack)...
            >
            > Jonas

            Don't forget the possibilities of ":imap <expr> {lhs} {rhs}" and ":imap {lhs}
            <C-R>={expression}".


            Best regards,
            Tony.
            --
            "The best thing for being sad," replied Merlin, beginning to puff and
            blow, "is to learn something. That's the only thing that never fails.
            You may grow old and trembling in your anatomies, you may lie awake at
            night listening to the disorder of your veins, you may miss your only
            love, you may see the world about you devastated by evil lunatics, or
            know your honour trampled in the sewers of baser minds. There is only
            one thing for it then -- to learn. Learn why the world wags and what
            wags it. That is the only thing which the mind can never exhaust,
            never alienate, never be tortured by, never fear or distrust, and never
            dream of regretting. Learning is the only thing for you. Look what a
            lot of things there are to learn."
            -- T.H. White, "The Once and Future King"

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