This works:

execute pathogen#infect('bundle/ruby/{}')

But this doesn't:

autocmd FileType * execute pathogen#infect('bundle/ruby/{}')

Nor this:

autocmd FileType * :execute pathogen#infect('bundle/ruby/{}')

Nor about 3 other things I tried.

UPDATE: This works:

autocmd BufWinEnter * execute '!ls'

But not this:

autocmd FileType * execute '!ls'


Possibly related: FileType autocommand not working in Neovim

  • Is it Vim or Neovim? Do you even have filetype on? Why do you use pathogen at all?
    – Matt
    Commented Jun 11, 2020 at 4:05

1 Answer 1


My guess: plugin managers need to be triggered within the scope of .vimrc execution.

After that, it's too late, files under {rtp}/plugin can't be loaded. And I'm afraid it's the same with file {rtp}/ftplugin as they are also triggered by FileType before your autocommand is triggered.

see :h starting-something.

At best the plugin manager you're using has a way to load plugins if some conditions are detected. You'll need to read its documentation in that case. I know a few elaborated plugin managers have this feature.

NB: if the plugin you're trying to use is correctly written: ftplugin files (in your case as I read "ruby") that depends on autoload plugin files, then this should not be a problem: no need to bother with this.

  • Thanks. I'm trying to follow the advice here: vi.stackexchange.com/a/6961/2021 for pathogen. Maybe it's just bad advice.
    – StevieD
    Commented Jun 11, 2020 at 0:53
  • What's really weird is autocmd BufEnter * execute pathogen#infect('bundle/ruby/ale') doesn't work but autocmd BufEnter * execute '!ls' does.
    – StevieD
    Commented Jun 11, 2020 at 0:55
  • Are you sure it doesn't work? Isn't &rtp value changed? Updating 'rtp' is the main purpose of the plugin manager. Loading the "plugins" is and has always been Vim task. plugin files are loaded after .vimrc has been loaded, ftplugin files are loaded on opening new buffer of the related filetype, autoload plugin files are loaded on demand. Commented Jun 11, 2020 at 8:34

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.