From a205f918f5797d9183f7f479360ed91bbce2b388 Mon Sep 17 00:00:00 2001 From: Peter Odding Date: Tue, 15 Mar 2011 23:00:55 +0100 Subject: Initial commit --- option.vim | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 option.vim (limited to 'option.vim') diff --git a/option.vim b/option.vim new file mode 100644 index 0000000..f785e1b --- /dev/null +++ b/option.vim @@ -0,0 +1,46 @@ +" Vim auto-load script +" Author: Peter Odding +" Last Change: March 15, 2011 +" URL: http://peterodding.com/code/vim/misc/ + +" Functions to parse multi-valued Vim options like &tags and &runtimepath. + +function! xolox#misc#option#split(value) + let values = split(a:value, '[^\\]\zs,') + return map(values, 's:unescape(v:val)') +endfunction + +function! s:unescape(s) + return substitute(a:s, '\\\([\\,]\)', '\1', 'g') +endfunction + +function! xolox#misc#option#join(values) + let values = copy(a:values) + call map(values, 's:escape(v:val)') + return join(values, ',') +endfunction + +function! s:escape(s) + return escape(a:s, ',\') +endfunction + +function! xolox#misc#option#split_tags(value) + let values = split(a:value, '[^\\]\zs,') + return map(values, 's:unescape_tags(v:val)') +endfunction + +function! s:unescape_tags(s) + return substitute(a:s, '\\\([\\, ]\)', '\1', 'g') +endfunction + +function! xolox#misc#option#join_tags(values) + let values = copy(a:values) + call map(values, 's:escape_tags(v:val)') + return join(values, ',') +endfunction + +function! s:escape_tags(s) + return escape(a:s, ', ') +endfunction + +" vim: ts=2 sw=2 et -- cgit v1.2.3