4

I'm trying to wrap my head around vim plugin development and I see a constant check on a variable to see if the plugin has already been loaded like:

if exists('g:loaded_plugin') || &cp
  finish
endif

This makes sense since it's trying to not load the plugin twice but why is it checking the second part?

I've searched on the documentation on the & and the cp command and it's not ringing anything on my head. As said in the documentation, the & is used to replay the last substitution command and the cp is to get to the next Error.

5

That checks for the compatible option being set. Usually you don't want plugins to be run when the compatible option is set, because well for one Vim wouldn't actually be compatible anymore and seconds of all, the compatible option e.g. does not allow for line continuations e.g.

let a = 'foobar'
     \ . ' and more text'

You could fix that, by setting a specific cpotions flag, but the general consensus in the Vim community seems to be, to just not bother and skip loading the plugin if Vim starts in compatible mode.

See :help :let-option

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.