Created
June 29, 2018 19:14
-
-
Save Houl/fcdf833ce12fae2039547f74931274f0 to your computer and use it in GitHub Desktop.
Virtcols2Vartabs()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" File: D2307.vim | |
" Created: 2018 Jun 29 | |
" Last Change: 2018 Jun 29 | |
" Version: 0.1 | |
" Author: Andy Wokula <[email protected]> | |
" License: Vim License, see :h license | |
" Virtcols2Vartabs({virt-columns}) (copy) | |
" | |
" return differences list (list of number) from explicit virtual columns, | |
" suitable for setting 'varsofttabstop'. | |
" | |
" {virt-columns} (list of number) virtual columns (each 2 or | |
" greater), in ascending order | |
" | |
" If {virt-columns} starts with 1, then the result starts with 0 which is | |
" probably not a valid vartabs entry. | |
" | |
" Example: | |
" :echo Virtcols2Vartabs([4,13,23,31,60]) | |
" => [3, 9, 10, 8, 29] | |
" | |
" Usage: | |
" :let &varsofttabstop = join(Virtcols2Vartabs([4,13,23,31,60]), ',') | |
" | |
" vim_dev: Off-by-one error in varsofttabstop description? | |
" 2018 Jun 29 François Ingelrest | |
" | |
func! Virtcols2Vartabs(vcols) "{{{ | |
if empty(a:vcols) | |
return [] | |
endif | |
return map(PairList(a:vcols, [1] + a:vcols), 'v:val[0] - v:val[1]') | |
endfunc "}}} | |
""func! PairList(list1, list2) "{{{ | |
"" let len = min([len(a:list1), len(a:list2)]) | |
"" return map(range(len), '[a:list1[v:val], a:list2[v:val]]') | |
""endfunc "}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment