On 26/10/09 18:02, Gary Johnson wrote:
>
> On 2009-10-26, Gabor Urban wrote:
>> Hi guys,
>>
>> I have written an own vim file which contains some function. Let
>> suppose, it is called 'myfuncs.vim'. How can I execute function
>> "PrtHeading" from the file. Should I load it before, and how.
>
> Assuming that you want to load 'myfuncs.vim' every time you run vim,
> the standard way to do this is to put that file in your
> ~/.vim/plugin directory on Unix, or your ~/vimfiles/plugin directory
> on Windows.  It will be loaded automatically every time you start
> vim.
>
> If you've just written or changed that file and you want to load it
> without restarting vim, use the :source command:
>
>      :so myfuncs.vim
>
> or, if myfuncs.vim isn't in the current working directory,
>
>      :so path/to/myfuncs.vim
>
> The function has to be defined before you can execute it.  If the
> function is defined in that file, sourcing that file is sufficient
> to define the function.  Then you can execute it with
>
>      :call PrtHeading()
>
> HTH,
> Gary


An alternative (in Vim 7) is to load the file on-demand. For this, you 
put it in ~/vimfiles/autoload (on Windows) or ~/.vim/autoload (on Unix) 
and invoke its functions as follows:

To execute function myfuncs#PrtHeading() with no parameters from 
autoload/myfuncs.vim, use

        :call myfuncs#PrtHeading()

The ":function" statement defining the function must contain the name of 
the script (without the .vim extension), see ":help autoload".


Best regards,
Tony.
-- 
If you've seen one redwood, you've seen them all.
                -- Ronald Reagan

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

Reply via email to