Skip to content

Instantly share code, notes, and snippets.

@AndrewVos
Created April 7, 2014 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndrewVos/10072796 to your computer and use it in GitHub Desktop.
Save AndrewVos/10072796 to your computer and use it in GitHub Desktop.
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