fixdup.vim 736 B

12345678910111213141516171819202122232425262728293031
  1. " Vim script to fix duplicate words in a .dic file vim: set ft=vim:
  2. "
  3. " Usage: Edit the .dic file and source this script.
  4. let deleted = 0
  5. " Start below the word count.
  6. let lnum = 2
  7. while lnum <= line('$')
  8. let word = getline(lnum)
  9. if word !~ '/'
  10. if search('^' . word . '/', 'w') != 0
  11. let deleted += 1
  12. exe lnum . "d"
  13. continue " don't increment lnum, it's already at the next word
  14. endif
  15. endif
  16. if lnum%1000 == 0
  17. echon "\r Processing line ".lnum. printf(" [ %02d%%]", lnum*100/line('$'))
  18. endif
  19. let lnum += 1
  20. endwhile
  21. if deleted == 0
  22. echomsg "No duplicate words found"
  23. elseif deleted == 1
  24. echomsg "Deleted 1 duplicate word"
  25. else
  26. echomsg printf("Deleted %d duplicate words", deleted)
  27. endif