FXux
FXux

Reputation: 435

Add has('vim_starting') in the start of .vimrc

What is the reason of adding:

if has('vim_starting')
  set nocompatible
endif

In the start of a .vimrc file?

Upvotes: 2

Views: 395

Answers (1)

phd
phd

Reputation: 94483

has("vim_starting") returns true on startup, false when running. The check is useful for the case when .vimrc is manually sourced with :source ~/.vimrc — it prevents execution of commands that have to be executed only once at startup.

Protecting set nocompatible is useful because the command also sets a lot of other options.

Upvotes: 4

Related Questions