diff options
Diffstat (limited to 'vim/autoload/option.vim')
-rw-r--r-- | vim/autoload/option.vim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/vim/autoload/option.vim b/vim/autoload/option.vim new file mode 100644 index 00000000..49fbf1a4 --- /dev/null +++ b/vim/autoload/option.vim @@ -0,0 +1,17 @@ +" 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(copy(parts), 'substitute(v:val, ''\\,'', '','', ''g'')') +endfunction + +" Escape the right-hand side of a :set option value +" +function! option#Escape(expr) abort + return escape(a:expr, ' |"\') +endfunction |