ih4cku / blog

deprecated, Git issues are great for writing blogs :)
2 stars 0 forks source link

vim autoload #73

Open ih4cku opened 7 years ago

ih4cku commented 7 years ago

Autoloading is an important concept in writing vim plugins.

Autoload let you delay loading code until it's actually needed.

When running a command like below:

cal somefile#func()

If the function is already been loaded, vim just call it directly. Otherwise, vim will look for the file autoload/somefile.vim in ~/.vim/ directory and any bundle directories.

In the file, the function is defined like this:

function somefile#func()
...
endfunction

Multiple # can be used to represent subdirectories.

References