Created
April 7, 2014 23:21
-
-
Save AndrewVos/10072796 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function! HighlightDate(date) | |
exec "syntax match TodoDateBeforeToday '" . a:date . "'" | |
highlight link TodoDateBeforeToday TodoRed | |
endfunction | |
function! UpdateDateHighlights() | |
let l:match = '\[\(\d\{2}\)\-\(\d\{2}\)\-\(\d\{4}\)\]' | |
let l:yearToday = str2nr(strftime("%Y")) | |
let l:line = 0 | |
while l:line < line('$') | |
let l:date = matchlist(getline(l:line), l:match) | |
if len(l:date) > 0 | |
let l:day = l:date[1] | |
let l:month = l:date[2] | |
let l:year = l:date[3] | |
if l:year < l:yearToday | |
call HighlightDate(l:date[0]) | |
endif | |
endif | |
let l:line = l:line + 1 | |
endwhile | |
endfunction | |
autocmd BufRead,InsertEnter,InsertLeave * call UpdateDateHighlights() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment