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

is there better way to define a customer Command like F[oobar]

Expand Messages
  • Kent
    many vim build in commands have abbreviation, e.g. ... user can type :d :de :del :dele ...delete Is there a better way to define a customer command (:command!
    Message 1 of 4 , Apr 8, 2013
    • 0 Attachment
      many vim build in commands have abbreviation, e.g.

      :d[elete]

      user can type :d :de :del :dele ...delete

      Is there a better way to define a customer command (:command! Foobar)
      like it too?

      e.g.

      F[oobar]

      what I can think of is, defining 6 commands, calling same function

      F
      Fo
      Foo
      ....

      Foobar

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

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Tim Chase
      ... This should just work out-of-the-box, according to ... As long as there s no ambiguity in the command, the shortest unambiguous form should work. So you
      Message 2 of 4 , Apr 8, 2013
      • 0 Attachment
        On 2013-04-09 01:00, Kent wrote:
        > many vim build in commands have abbreviation, e.g.
        >
        > :d[elete]
        >
        > user can type :d :de :del :dele ...delete
        >
        > Is there a better way to define a customer command (:command!
        > Foobar) like it too?

        This should just work out-of-the-box, according to

        :help user-cmd-ambiguous

        As long as there's no ambiguity in the command, the shortest
        unambiguous form should work. So you can do

        :command! Foobar echo "Foobar!"
        :command! Foofoo echo "Foofoo!"

        and all you have to type is either "Foob" or "Foof" and Vim will
        choose the right command. So I guess the answer is "don't make
        ambiguous commands, if you want to keep them short"

        -tim


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

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • Paul Isambert
        ... You can use an incomplete command name if there is no ambiguity with another command; for instance, if Foobar is your only command beginning with F, then
        Message 3 of 4 , Apr 9, 2013
        • 0 Attachment
          Kent <kent.yuan@...> a écrit:
          > many vim build in commands have abbreviation, e.g.
          >
          > :d[elete]
          >
          > user can type :d :de :del :dele ...delete
          >
          > Is there a better way to define a customer command (:command! Foobar)
          > like it too?
          >
          > e.g.
          >
          > F[oobar]
          >
          > what I can think of is, defining 6 commands, calling same function
          >
          > F
          > Fo
          > Foo
          > ....
          >
          > Foobar

          You can use an incomplete command name if there is no ambiguity with
          another command; for instance, if Foobar is your only command
          beginning with F, then F, Fo, Foo, etc. are all ok. However, if you
          have Funk too, then you must at least use Fo or Fu, and so on and so
          forth.

          Defining 6 commands or more will work for the most recently defined
          command, in case of ambiguity, all the other being be deleted (with
          Foobar and Funk, F will only work for one or the other).

          Best,
          Paul

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

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        • Kent
          thanks Tim, thanks Paul my test yesterday failed because there was another plugin defined an ambiguous command.... :( ... -- -- You received this message from
          Message 4 of 4 , Apr 9, 2013
          • 0 Attachment
            thanks Tim, thanks Paul

            my test yesterday failed because there was another plugin defined an
            ambiguous command.... :(





            On Tue, Apr 9, 2013 at 9:22 AM, Paul Isambert <zappathustra@...> wrote:
            > Kent <kent.yuan@...> a écrit:
            >> many vim build in commands have abbreviation, e.g.
            >>
            >> :d[elete]
            >>
            >> user can type :d :de :del :dele ...delete
            >>
            >> Is there a better way to define a customer command (:command! Foobar)
            >> like it too?
            >>
            >> e.g.
            >>
            >> F[oobar]
            >>
            >> what I can think of is, defining 6 commands, calling same function
            >>
            >> F
            >> Fo
            >> Foo
            >> ....
            >>
            >> Foobar
            >
            > You can use an incomplete command name if there is no ambiguity with
            > another command; for instance, if Foobar is your only command
            > beginning with F, then F, Fo, Foo, etc. are all ok. However, if you
            > have Funk too, then you must at least use Fo or Fu, and so on and so
            > forth.
            >
            > Defining 6 commands or more will work for the most recently defined
            > command, in case of ambiguity, all the other being be deleted (with
            > Foobar and Funk, F will only work for one or the other).
            >
            > Best,
            > Paul
            >
            > --
            > --
            > 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
            >
            > ---
            > You received this message because you are subscribed to the Google Groups "vim_use" group.
            > To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            > For more options, visit https://groups.google.com/groups/opt_out.
            >
            >

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

            ---
            You received this message because you are subscribed to the Google Groups "vim_use" group.
            To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
            For more options, visit https://groups.google.com/groups/opt_out.
          Your message has been successfully submitted and would be delivered to recipients shortly.