diff options
author | Peter Odding <peter@peterodding.com> | 2011-03-15 23:00:55 +0100 |
---|---|---|
committer | Peter Odding <peter@peterodding.com> | 2011-03-15 23:00:55 +0100 |
commit | a205f918f5797d9183f7f479360ed91bbce2b388 (patch) | |
tree | d2cf19205d9cd875a463b6835cd249cd183f9d28 /option.vim | |
download | vim-easytags-a205f918f5797d9183f7f479360ed91bbce2b388.tar.gz |
Initial commit
Diffstat (limited to 'option.vim')
-rw-r--r-- | option.vim | 46 |
1 files changed, 46 insertions, 0 deletions
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 <peter@peterodding.com> +" 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 |