Monthly Archives: October 2012

Ékezet gyilkolás vim-mel

" Remove diacritical signs from characters in specified range of lines.
" Examples of characters replaced: á -> a, ç -> c, Á -> A, Ç -> C.
function! s:RemoveDiacritics(line1, line2)
  let diacs = 'áâãàçéêíóôõöőüúű'  " lowercase diacritical signs
  let repls = 'aaaaceeiooooouuu'  " corresponding replacements
  let diacs .= toupper(diacs)
  let repls .= toupper(repls)
  let all = join(getline(a:line1, a:line2), "\n")
  call setline(a:line1, split(tr(all, diacs, repls), "\n"))
endfunction
command! -range=% RemoveDiacritics call s:RemoveDiacritics(<line1>, <line2>)
Ezek után már csak meg kell nyitnunk az ékezetes szövegfile-unkat vim-ben és kiadni a :RemoveDiacritics parancsot – voila! ]]>