I have an autocommand that is supposed to register a different autocommand whenever I enter a buffer where a certain condition is met:
let w:contextlist_open = 1 augroup LaunchShowContext autocmd! autocmd BufEnter * \ if (exists("w:contextlist_open") && w:contextlist_open == 1) \ | :autocmd CursorHold * call ShowContext() \ | endif augroup END
If I fire up another buffer and switch back and forth, I get
Error detected while processing CursorHold Autocommands for "*":
E580: :endif without :if: endif. I suspect this is because Vim thinks the
endif belongs with the second autocommand rather than the first, and I'm not sure how to make it so that it goes with the correct one. I tried wrapping the
autocmd CursorHold * call ShowContext() in parentheses, but that seems to give me other problems.