I'm trying to write a script to take a bunch of vim sources in plugins and combine them into a single vimrc that I'm going to treat as an essentially opaque binary file. I'm doing this partially to simplify the process of deploying my vimrc to a new machine and partially to get more familiar with the ins and outs of vimscript/viml.

To start, I'm taking an old plugin https://github.com/kana/vim-arpeggio, extracting all the non-test .vim files and concatenating them with my ordinary .vimrc.

When I do that though, I see a bunch of error messages this:

E746: Function name does not match script file name: arpeggio#_map_or_list

The file is defined in bundle/autoload/arpeggio.vim as follows:

140:function! arpeggio#_map_or_list(modes, remap_p, q_args) "{{{2

I had assumed that the arpeggio# was just another form of namespacing in vim, but it seems there's more to the story.

Does it have any intrinsic relation to literal name of a file? Is it possible to trick vim into not performing this check?

2 Answers 2


That's an autoload function. They are used to allow functions to be loaded only when required (when they are called), so that they don't impact Vim's startup time, and for packaging of functions into libraries.

From :help autoload

Using a script in the "autoload" directory is simpler, but requires using exactly the right file name. A function that can be autoloaded has a name like this:

   :call filename#funcname()

When such a function is called, and it is not defined yet, Vim will search the "autoload" directories in 'runtimepath' for a script file called "filename.vim". For example "~/.vim/autoload/filename.vim".

See also :help 41.15.

If you want to move these functions into your .vimrc (losing the autoload benefits), you can simply rename them not to contain the # character, (and to start with an upper case letter), but I completely agree with Luc Hermitte that it's not a good idea to do so.

  • I think Emacs has a similar-ish autoload mechanism using ;;; AUTOLOAD that isn't file oriented and delays compilation of an s-expression. Does vim have something similar for delaying parsing of a single function? Commented Aug 19, 2017 at 20:05
  • @GregoryNisbet I don't believe so. As far as I'm aware, this is the only mechanism provided for that functionality.
    – Rich
    Commented Aug 24, 2017 at 9:40

You don't want to do that for several reasons.

Autoload functions need to be in specific autoload plugin files. If you rename the functions, you'll have to rename all their calls.

There exist script variables and script functions. They are like static variables in C: their visibility is restricted to one file. You can be sure that if two different files have a s:foo variable and a s:bar() function, they are certainly used for totally unrelated things.

There exist syntax scripts that are loaded according to specific rules. You don't want to load C syntax highlighting while editing Python files for instance.

The same is true with ftplugins. They are loaded on the fly, when they need to be loaded. You'd need to replace their automated loading with Vim 5 tricks based on autocommands. Colorscheme and compiler plugins are also loaded in their own way.

You really don't want to do this. If vim plugins are made of several files, there is a reason. Instead, I encourage you to learn stuff like rsync, tar, git and use them to define a simplified way to deploy your configuration to other places.

If you really want to delve into scripting vim, one of the important step consists in understanding Vim way of splitting the venerable .exrc into multiple files organized into specific directories each with a specific raison d'être.

BTW: autoload plugin files serve two purposes:

  • delayed/on-the-fly loading that improve vim starting time
  • defining libraries of functions

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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