Yes, there is :) Example:
function! Testing()
" this is the droid you're looking for
echo substitute(expand('<sfile>'), '.*\(\.\.\|\s\)', '', '')
" compare with this (not what you want, just for reference)
echo expand('<sfile>')
endfunction
function! OutsideTesting()
call Testing()
endfunction
And the test:
:call Testing()
:call OutsideTesting()
Surprisingly perhaps, the solution is based on <sfile>
, which returns something like function Testing
(if called directly from Testing
) or function OutsideTesting..Testing
, if called from the "outer" function. See :h <sfile>
. The substitute()
call removes the first part of the expansion and leaves only the inner function name (you can also change the substitution pattern to leave only the outer function name instead - depends on what you want).