0

Need some help on this to explain why I can't call a Plugin command from autocmd in VIM:

autocmd! Syntax * if !empty(&l:filetype) | RainbowToggleOn | endif

Vim detects a syntax error with:

Error detected while processing Syntax Auto commands for "*":
E488: Trailing characters:  RainbowToggleOn | endif
cmcginty
  • 113,384
  • 42
  • 163
  • 163
  • 1
    mmm, no trailing characters there apparently, and I can't reproduce this error with this line. – sidyll Apr 07 '16 at 17:28

1 Answers1

0

I believe this issue caused by a reversed loading order. For some reason my autocmd in vimrc is running before the plugin is loaded. My guess is that it has something to do with the way Rainbow.vim is structured.

According to this answer the loading order is correct: Does Vim load plugins after loading vimrc?

So I was able to solve by delaying the ref lookup of the command:

autocmd! Syntax * if !empty(&l:filetype) | exec 'RainbowToggleOn' | endif
Community
  • 1
  • 1
cmcginty
  • 113,384
  • 42
  • 163
  • 163