tags:

views:

47

answers:

2

Hi all, I have problem with basic VIM function:(I tried googling and cannot find the answer)

  1. How can I list all custom function.(I did :function and cannot find my custom function)
  2. How can I get the definition of the function in the custom function list (or where they are stored).

Thank you for your help

+4  A: 

Suppose your function is called MyFunction, then the following works for me:

:verbose function My<tab>

(for <tab> I mean actually press tab)

if your function is loaded in vim it should show up there and you can see where it was defined.

skeept
Thanks, now I can do (:verbose function to list all function and their location. :verbose function partOfName<tab>, and :verbose function functionName)
kite
@kite `verbose function` will not list *all* functions, only those that are not anonymous. For example, some of my plugins does not contain non-anonymous functions at all.
ZyX
+1  A: 

If you cannot find your custom function in output of function without arguments, then it is probably an anonymous function declared like that:

let g:dict={}
function g:dict.f()
    echo "here"
endfunction

In this case the only way to get its definition is to use function g:dict.f (prepend verbose as @skeept suggested to know where it is defined). Note that you cannot use tab completion here and you cannot get a list of all anonymous functions.

Instead of g:dict.f in function g:dict.f you can use function {N}, where N is any expression that returns anonymous function number, for example function {substitute(string(g:dict.f), '^.*\(\d\+\).*$', '\1', '')}. Or just function {242} if all you get is a error like that: Error detected while processing function 243..242: and want to see the definition of function 242.

ZyX
Thanks for the anonymous function method
kite