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