1

I'd like to put all my custom functions into autoload folder, but I have functions with the same name. How should I organize them?

  • 1
    Could you be a little bit more specific about the names of these functions about what they do, and why you want them to have the same name as this would mean they are de-facto defined in the same file and thus I don't see the problem. – Luc Hermitte Dec 9 '16 at 14:02
4

Especially with autoload, there should be no same-name clashes. The first part of the autoload function is determined (and enforced) to be the autoload script name, and you're free to choose any function name yourself.

As for organizing, this is a very broad question, so here's a broad answer:

Put related stuff together. Many small modules are better than fewer larger ones.

If you have some Vim plugins installed, have a look at how they are organized. Also, there are thousands of personal ~/.vimrc files shared on Github; that might give you a clue, too.

I personally distinguish between generic stuff, things that I may one day publish as a plugin, and purely personal shortcuts, macros, helpers. The latter, I lump together in larger files, separated into mappings, commands, environment tweaks, plugin customizations, and so on. The former, I keep neatly separated by functionality. I usually start with one autoload/{pluginname}.vim module. If there are parts that are only needed by parts of the plugin, I might separate further into autoload/{pluginname}/commands.vim and autoload/{pluginname}/visualmode.vim, for example. After all, the main purpose of autoload is delaying load until its first use.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.