All pastes #102166 Raw Edit

Miscellany

public text v1 · immutable
#102166 ·published 2006-07-27 11:32 UTC
rendered paste body
func! StrICmp(str1, str2)
    if (a:str1 <? a:str2)
       return -1
    elseif (a:str1 >? a:str2)
       return 1
    else
       return 0
    endif
endfunction

fun! ListSort()

    let ai_revert = &l:ai
    let tw_revert = &l:tw
    setlocal autoindent textwidth=80

    normal! gv"ay
    let text = matchstr(@a, '\s*\zs.*\ze\s*')
    let list = split(text, '\_s*,\_s*')
    call sort(list, s:cmpref)
    let @a = join(list, ', ')
    normal! gv"ap

    normal! >>
    normal! >>
    normal! gqq

    let &l:tw = tw_revert
    let &l:ai = ai_revert

endfun