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

Erro: Unknow function:

Expand Messages
  • Xaut Jzd
    This is the first time to write vim plugin, so I try to write an hello plugin, this is my repository url: ... so please help! -- -- You received this message
    Message 1 of 4 , Aug 12, 2014
      This is the first time to write vim plugin, so I try to write an hello plugin, this is my repository url:

      autoload/hello.vim:

      >function! s:Hello()
      > echo "hello, my name is xautjzd!"
      >endfunction

      plugin/hello.vim:

      >command Hello :call <SID>Hello()

      but after I installed the plugin via vundle, open vim and execute `Hello` command,but get the error:

      > unknow function:<SNR>

      so please help!

      --
      --
      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/d/optout.
    • Ben Fritz
      ... In a user command, you can just use s:Hello(). IIUC you only need when defining mappings and menus. -- -- You received this message from the
      Message 2 of 4 , Aug 12, 2014
        On Tuesday, August 12, 2014 4:34:09 AM UTC-5, Xaut Jzd wrote:
        >
        > >command Hello :call <SID>Hello()
        >
        > but after I installed the plugin via vundle, open vim and execute `Hello` command,but get the error:
        >
        > > unknow function:<SNR>
        >

        In a user command, you can just use s:Hello(). IIUC you only need <SID> when defining mappings and menus.

        --
        --
        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/d/optout.
      • Павлов Николай Алекса
        ... Hash: SHA512 ... Functions defined with s: are only accessible with s: or within the file you defined it in. You must do one of the following: 1. Use
        Message 3 of 4 , Aug 12, 2014
          -----BEGIN PGP SIGNED MESSAGE-----
          Hash: SHA512

          On August 12, 2014 1:34:09 PM GMT+03:00, Xaut Jzd <xautjzd@...> wrote:
          >This is the first time to write vim plugin, so I try to write an hello
          >plugin, this is my repository url:
          >
          >autoload/hello.vim:
          >
          >>function! s:Hello()
          >> echo "hello, my name is xautjzd!"
          >>endfunction
          >
          >plugin/hello.vim:

          Functions defined with s: are only accessible with s: or <SID> within the file you defined it in. You must do one of the following:

          1. Use global function name. Since you are using autoload/hello.vim this name should be hello#Hello or you will not have your function autoloaded. You may still take any name and load your function with :runtime.
          2. Put s:Hello into the same file you defined :Hello.
          3. Use expanded variant of function name alongside with loading this function manually with :runtime. Check out :h <SID>, it will tell you how to get the expanded variant.

          >
          >>command Hello :call <SID>Hello()
          >
          >but after I installed the plugin via vundle, open vim and execute
          >`Hello` command,but get the error:
          >
          >> unknow function:<SNR>
          >
          >so please help!

          -----BEGIN PGP SIGNATURE-----
          Version: APG v1.1.1

          iQI1BAEBCgAfBQJT6imiGBxaeVggPHp5eC52aW1AZ21haWwuY29tPgAKCRCf3UKj
          HhHSvmQrD/92gXvaALTzP4tSeBEW6x2CVW8MFrh8J9v0QglvHn9SmY4bOpcnri2h
          6v4mqoQsn4fNac2/XA9xxSxE3Y/sfgPKk5ZWZFLu+tEyg32ruqEp05wfGWu646zK
          3r4YAcEw3HaHKtpaPTfBCXzy3Ar3azD66PO7RDSdXiXwgVDzXMcejpiOjra6stCB
          fuj5Ej/hKKmZn6Vvi7yNW1cxrWPFa492Cbru/JSN/PuoIdc44Je4tL8pzF/Vfo5x
          sU1WBu3X8l1djArYAhD1Ock+XlnsA52lkhldwbWUSsYs4MBXxUvBQqhPvlkPsqJR
          cxXfTSDo6yssqDLG6GBphzEEpi7L2CMe02wAk2vUFMyjZY7HYhqmie3Hzw4ubfSW
          9QTWeGe6EJZZ9Dm3AVeoaDUZGmHkxvub+/fq1zLpzJj58/uQ4ABKMRGceteAz3y+
          gOeG656BkmENzY+oHk/GoITpeKXNzJbuCAUvLLlqDtVo9EbxM4O2OfhHKjizEE+/
          hAq6//Nwkoun1x1ORH2M7dk3NXnX4CiBDFECrXrBSzXk0OK3OO6+kRHdMTDavlxq
          uf0/JRJp1rHh+t0fIu+QN8q42x20FpNYGFRXqPJWie2i8g+lsNqDybui47O7qD70
          4o5MLhpCvCOAB+ugHA2xY2LUdhTRjfbXlwPBDHP8S9zcFxyYMz/QpQ==
          =k3JI
          -----END PGP SIGNATURE-----

          --
          --
          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/d/optout.
        • Ben Fritz
          ... Right, that too. I guess I should have paid more attention to the file names. You re using autoload wrong. If you are using autoload, you need to define a
          Message 4 of 4 , Aug 12, 2014
            On Tuesday, August 12, 2014 9:50:48 AM UTC-5, ZyX wrote:
            > >
            > >autoload/hello.vim:
            > >
            > >>function! s:Hello()
            > >> echo "hello, my name is xautjzd!"
            > >>endfunction
            > >
            > >plugin/hello.vim:
            >
            > Functions defined with s: are only accessible with s: or <SID> within the file you defined it in. You must do one of the following:
            >
            > 1. Use global function name. Since you are using autoload/hello.vim this name should be hello#Hello or you will not have your function autoloaded. You may still take any name and load your function with :runtime.
            > 2. Put s:Hello into the same file you defined :Hello.
            > 3. Use expanded variant of function name alongside with loading this function manually with :runtime. Check out :h <SID>, it will tell you how to get the expanded variant.
            >

            Right, that too. I guess I should have paid more attention to the file
            names.

            You're using autoload wrong. If you are using autoload, you need to
            define a global name that can be used by your plugin script, formatted
            in a way that Vim expects so it can automatically find the correct
            autoload script to source to define the function.

            In your case, autoload/hello.vim should contain:

            function hello#Hello()
            echo "hello, my name is xautjzd!"
            endfunction

            and plugin/hello.vim should be:

            command Hello call hello#Hello()

            --
            --
            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/d/optout.
          Your message has been successfully submitted and would be delivered to recipients shortly.