<commit_before>
function! FixTOCLine(beginning, colonCol)
    let l = strlen(a:beginning)
    let c = 0
    let dots = ""
    while c < (a:colonCol - l)
        let dots = dots . "."
        let c += 1
    endwhile
    return (a:beginning . dots . ":")
endfunction

function! BuildTOC()
    let lnum = getpos(".")[1]
    call append(lnum - 1, "<<<")
    call append(lnum, ">>>")
    :g/^\d\+\./co/>>>/-
    :g/^<<</,/^>>>/s/ {{{\d\s*//
    :g/^<<</,/^>>>/s/\*/|/g
    :g/^<<</,/^>>>/s/^\ze\d\.\d\+\./      /
    :g/^<<</,/^>>>/s/^\ze\d\d\.\d\+\./     /
    :g/^<<</,/^>>>/s/^\ze\d\.\d\+/    /
    :g/^<<</,/^>>>/s/^\ze\d\d\.\d\+/   /
    :g/^<<</,/^>>>/s/^\ze\d\./  /
    :g/^<<</,/^>>>/s/^\ze\d\d\./ /
    :g/^\s\+0\. Content/d
    :g/<<</+,/>>>/-s/^\(.\{-}\)\(\s\+\)\ze |/\=FixTOCLine(submatch(1), 45)/
    :g/<<</d
    :g/>>>/d
endfunction

command! BuildNewTableOfContents silent! call BuildTOC()

function! JustifyCurrentLine()
    let cline = getline('.')
    let matches = matchlist(cline, '^\(.*\)\s\+\(\*.*\)$')
    let st = matches[1]
    let fin = matches[2]
    let spcnum = 78 - strlen(st) - strlen(fin)
    let c = 0
    let spcs = ""
    while c < spcnum
        let spcs = spcs . " "
        let c = c + 1
    endwhile
    let newline = st . spcs . fin
    :norm dd
    let lnum = getpos('.')[1]
    call append(lnum - 1, newline)
endfunction

nmap ,jt :call JustifyCurrentLine()<cr><commit_msg>Don't use nmap. It's just for legacy vi compatibility.<commit_after>
function! FixTOCLine(beginning, colonCol)
    let l = strlen(a:beginning)
    let c = 0
    let dots = ""
    while c < (a:colonCol - l)
        let dots = dots . "."
        let c += 1
    endwhile
    return (a:beginning . dots . ":")
endfunction

function! BuildTOC()
    let lnum = getpos(".")[1]
    call append(lnum - 1, "<<<")
    call append(lnum, ">>>")
    :g/^\d\+\./co/>>>/-
    :g/^<<</,/^>>>/s/ {{{\d\s*//
    :g/^<<</,/^>>>/s/\*/|/g
    :g/^<<</,/^>>>/s/^\ze\d\.\d\+\./      /
    :g/^<<</,/^>>>/s/^\ze\d\d\.\d\+\./     /
    :g/^<<</,/^>>>/s/^\ze\d\.\d\+/    /
    :g/^<<</,/^>>>/s/^\ze\d\d\.\d\+/   /
    :g/^<<</,/^>>>/s/^\ze\d\./  /
    :g/^<<</,/^>>>/s/^\ze\d\d\./ /
    :g/^\s\+0\. Content/d
    :g/<<</+,/>>>/-s/^\(.\{-}\)\(\s\+\)\ze |/\=FixTOCLine(submatch(1), 45)/
    :g/<<</d
    :g/>>>/d
endfunction

command! BuildNewTableOfContents silent! call BuildTOC()

function! JustifyCurrentLine()
    let cline = getline('.')
    let matches = matchlist(cline, '^\(.*\)\s\+\(\*.*\)$')
    let st = matches[1]
    let fin = matches[2]
    let spcnum = 78 - strlen(st) - strlen(fin)
    let c = 0
    let spcs = ""
    while c < spcnum
        let spcs = spcs . " "
        let c = c + 1
    endwhile
    let newline = st . spcs . fin
    :norm dd
    let lnum = getpos('.')[1]
    call append(lnum - 1, newline)
endfunction

nnoremap ,jt :<C-u>call JustifyCurrentLine()<cr>
{'fraction_non_alphanumeric': 0.29491643454038996, 'fraction_numerical': 0.011142061281337047, 'mean_word_length': 1.7839147286821706, 'pattern_counts': {'":': 2, '<': 76, '<?xml version=': 0, '>': 78, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6161118', 'n_tokens_mistral': 1312, 'n_tokens_neox': 1267, 'n_words': 237}