cleanadd.vim 934 B

123456789101112131415161718192021222324252627282930313233
  1. " Vim script to clean the ll.xxxxx.add files of commented out entries
  2. " Author: Antonio Colombo, Bram Moolenaar
  3. " Last Update: 2008 Jun 3
  4. " Time in seconds after last time an ll.xxxxx.add file was updated
  5. " Default is one second.
  6. " If you invoke this script often set it to something bigger, e.g. 60 * 60
  7. " (one hour)
  8. if !exists("g:spell_clean_limit")
  9. let g:spell_clean_limit = 1
  10. endif
  11. " Loop over all the runtime/spell/*.add files.
  12. " Delete all comment lines, except the ones starting with ##.
  13. for s:fname in split(globpath(&rtp, "spell/*.add"), "\n")
  14. if filewritable(s:fname) && localtime() - getftime(s:fname) > g:spell_clean_limit
  15. if exists('*fnameescape')
  16. let s:f = fnameescape(s:fname)
  17. else
  18. let s:f = escape(s:fname, ' \|<')
  19. endif
  20. silent exe "tab split " . s:f
  21. echo "Processing" s:f
  22. silent! g/^#[^#]/d
  23. silent update
  24. close
  25. unlet s:f
  26. endif
  27. endfor
  28. unlet s:fname
  29. echo "Done"