Reputation: 435
What is the reason of adding:
if has('vim_starting')
set nocompatible
endif
In the start of a .vimrc
file?
Upvotes: 2
Views: 395
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