Please explain following two lines found in synload.vim file:
let s:cpo_save = &cpo
set cpo&vim
What is vim in the last expression? What is result of such an expression, and what does it affect?
Please explain following two lines found in synload.vim file:
let s:cpo_save = &cpo
set cpo&vim
What is vim in the last expression? What is result of such an expression, and what does it affect?
It resets 'cpo'
value to its default value.
Some people may be running vim in compatible mode, by choice or not. In those cases, various things would be inhibited, things we usually rely upon when writing plugins -- in particular :h line-continuation. As a consequence, the plugins would emit many error messages.
Resetting 'cpo' to its factory setting, the plugin becomes resilient to these hostile (IMO) configurations.
This syntax could be used with many (all?) vim options. Before doing that, we record the old value in order to properly restore it afterward
let s:cpo_save = &cpo
set cpo&vim
.
. plugin code
.
let &cpo = s:cpo_save
What is vim in the last expression?See:h set-&vim– Matt Mar 25 '20 at 04:46:h &vim, which will find the help page Matt mentioned; just FYI for the next time you're confused by something in Vim: just try entering stuff in:helpand see what comes up :-) Using:help something<Tab>to get the autocomplete list is also very useful. – Martin Tournoij Mar 25 '20 at 22:32