I have been using Vim for more than 6 years and have compiled it from source a couple of times during that period. Over the years my vimrc did grow. Now, I am trying to clean my vimrc and I came upon a dinosaur configuration: has("autocmd").

When I started using Vim I copied my first vimrc from a colleague and it already contained a condition with a call to has("autocmd"), as follows:

if has("autocmd")
    " ... several autocmds, most of them on the FileType event

Vim (likely) can be compiled without autocmd support, and, I believe, during those days it was still possible to find a Vim instance without autocmd support.

Over the years some 60-70% of my vimrc migrated into that if block, and now that block is huge (300+ lines). If I run a Vim without autocmd support I'll lose the majority of my vimrc.

On the other hand, I believe that has("autocmd") is rather irrelevant these days. And, therefore, I want to get rid of that if altogether.

I looked through Vim's configure.in and there is no way to explicitly disable autocmd in there. Looking through neovim's source tree I do not see an Find* cmake for autocmd either, I do not believe that neovim can be compiled without autocmd.

The Question

Since "relevance" is a rather opinionated topic, let's focus on the objective points of has("autocmd"):

  • Under which conditions Vim can be/is compiled without autocmd support?

  • Are there official compiled packages/distribution of Vim without autocmd support? (Maybe on embedded devices)

  • Both questions above but for neovim.

  • 3
    vim-tiny, often used as a vi replacement (debian, ubuntu I think), doesn't have autocmd support, or support for much. if 1 is more useful in this case. – Antony Jul 4 '16 at 0:30
  • 2
    IIRC the first thing neovim people have done when they forked Vim was to drop support for all build modes except huge, and for targets such as Commodore Amiga and the like. – Sato Katsura Jul 4 '16 at 5:41
  • 1
    also vim-small package does not have autocommands. – Christian Brabandt Jul 4 '16 at 9:06
  1. If you install from your package manager a Vim with the feature set tiny or small, you won't get autocommand support. Also if you compile your own Vim and disable autocommand feature in feature.h (or used the --with-features=small or --with-features=tiny argument)

  2. depends on how you install Vim. Debian/Ubuntu provides official tiny and I think small packages.

  3. don't know.

In short, that line is still relevant and does not hurt.

  • Well, it hurts plugin writers, but only a little. Most of them have developed a Stockholm syndrome kind of fondness for these things by now. ;) – Sato Katsura Jul 4 '16 at 9:25
  • Cool, I now see the AC_DEFINE(FEAT_TINY) and AC_DEFINE(FEAT_SMALL). neovim does not use ~/.vimrc (just learned that), so, yeah, leaving the if has("autocmd") will not really harm. – grochmal Jul 5 '16 at 0:21
  • 1
    As the OP guessed, neovim will always be compiled with the autocmd features, and properly return has("autocmd"). – PhilippFrank Jul 14 '16 at 9:37

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.