<commit_before>
function! HandleURL()
  let s:uri = matchstr(getline("."), "https\\?://[^ ]*")
  if s:uri != ""
    silent execute "! open '".s:uri."'"
    redraw!
    return 1
  endif
endfunction

function! ToggleBox()
  let cline = getline(".")
  if match(cline, "^ \*\\[ \\]") != -1
    normal! ^lrx
  elseif match(cline, "^ \*\\[.\\]") != -1
    execute "normal! ^lr "
  end
  " not a box line -- don't toggle
  normal! j
  " position cursor in the box, if there is one
  if match(cline, "^ \*\\[.\\]") != -1
    normal! ^l
  end
endfunction

function! Activate()
  if HandleURL()
    return
  endif
  call ToggleBox()
endfunction

nnoremap <buffer> <CR> :call Activate()<CR>
<commit_msg>vim: better URL handling<commit_after>
function! HandleURL()
  let s:uri = matchstr(getline("."), "https\\?://[^ ]*")
  if s:uri != ""
    silent execute "! open '".s:uri."'"
    redraw!
    return 1
  endif
endfunction

function! ToggleBox()
  let cline = getline(".")
  if match(cline, "^ \*\\[ \\]") != -1
    normal! ^lrx
  elseif match(cline, "^ \*\\[.\\]") != -1
    execute "normal! ^lr "
  end
  " not a box line -- don't toggle
  normal! j
  " position cursor in the box, if there is one
  if match(cline, "^ \*\\[.\\]") != -1
    normal! ^l
  end
endfunction

nnoremap <buffer> <CR> :call ToggleBox()<CR>
vnoremap <buffer> <CR> :call HandleURL()<CR>

{'fraction_non_alphanumeric': 0.20488165680473372, 'fraction_numerical': 0.005917159763313609, 'mean_word_length': 2.7899159663865545, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, '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': '770162', 'n_tokens_mistral': 534, 'n_tokens_neox': 504, 'n_words': 145}