23 lines
906 B
VimL
23 lines
906 B
VimL
" convert rows of numbers or text (as if pasted from excel column) to a tuple
|
|
function! ToTupleFunction() range
|
|
silent execute a:firstline . "," . a:lastline . "s/^/'/"
|
|
silent execute a:firstline . "," . a:lastline . "s/$/',/"
|
|
silent execute a:firstline . "," . a:lastline . "join"
|
|
silent execute "normal I("
|
|
silent execute "normal $xa)"
|
|
silent execute "normal ggVGYY"
|
|
endfunction
|
|
command! -range ToTuple <line1>,<line2> call ToTupleFunction()
|
|
|
|
" convert rows of numbers or text (as if pasted from excel column) to an array
|
|
function! ToArrayFunction() range
|
|
silent execute a:firstline . "," . a:lastline . "s/^/'/"
|
|
silent execute a:firstline . "," . a:lastline . "s/$/',/"
|
|
silent execute a:firstline . "," . a:lastline . "join"
|
|
silent execute "normal I["
|
|
silent execute "normal $xa]"
|
|
endfunction
|
|
command! -range ToArray <line1>,<line2> call ToArrayFunction()
|
|
|
|
|