On Tue, 14 Sep 2010, hsitz wrote:
I thought the rules for naming user functions in Vimscript were (1)
must begin with capital letter unless (2) using s: prefix. But I
noticed that in the code for the pathogen plugin the function names
don't meet either of those requirements. In the pathogen script the
function names all appear as lower case with what appears to be a (1)
local identifier followed by (2) the '#' sign, followed by (3) the
function name. Like this:
----------------------------------------------------------------
Split a path into a list.
function! pathogen#split(path) abort " {{{1
if type(a:path) == type([]) | return a:path | endif
let split = split(a:path,'\\\@<!\%(\\\\\)*\zs,')
return map(split,'substitute(v:val,''\\\([\\,]\)'',''\1'',"g")')
endfunction " }}}1
-------------------------------------------------------------
Is this form of function name documented? How does its functionality
differ, if at all, from version where the script scope identifier (s:)
is prefixed to a function name?
This is an autoload function, explained in-depth at:
:help write-library-script
The short story is that the first components are path and filename
components (sans '.vim') that identify the autoload path. The last is
the function name.
So, for example:
pathogen#split(path) would be defined on non-Windows in
~/.vim/autoload/pathogen.vim
other#library#split(path) could be in ~/.vim/autoload/other/library.vim
--
Best,
Ben
--
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