blob: 5ff44cedec0f92084b2ead09b109b22860a61ac0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
|
" Split a comma-separated option value into parts, accounting for escaped
" commas and leading whitespace as Vim itself does internally
"
function! option#Split(expr, ...) abort
if a:0 > 1
echoerr 'Too many arguments'
endif
let keepempty = a:0 ? a:1 : 0
let parts = split(a:expr, '\\\@<!,[, ]*', keepempty)
return map(parts, 'substitute(v:val, ''\\,'', '','', ''g'')')
endfunction
|