> Some vim options are boolean, i.e. integers with the possible values 0 and 1. You can, e.g., set `ai` and `noai` or use `let &ai = 1`. Other options are numeric/integer or string values.
>
> type(&option) can only be used to distinguish string from bool/int options. exist('&noai') returns 0, so it cannot be used to distinguish bool from int options. Is there another way to determine whether an option is a bool (an int that takes only the values 0 or 1) or an int?
Off my head:
function! IsBoolean (option)
if !exists("&" . a:option)
return 0
endif
let bool = 1
exe "let old = &" . a:option
try
exe "set no" . a:option
catch
let bool = 0
endtry
exe "let &" . a:option . " = " . old
return bool
endfunction
I’m not sure setting and resetting the option is 100% harmless for all
options, though.
Best,
Paul