Skip to content

Instantly share code, notes, and snippets.

@leihog
Created February 17, 2012 13:29
Show Gist options
  • Save leihog/1853449 to your computer and use it in GitHub Desktop.
Save leihog/1853449 to your computer and use it in GitHub Desktop.
Barebones example of how to make a simple vim syntax file.
" Barebones example of how to make a simple vim syntax file.
" Language: todofile
" Maintainer: leihog
"if exists ("b:current_syntax")
" finish
"endif
let b:current_syntax = "todo"
" v:folddashes a string that contains dashes to represent the foldlevel.
" v:foldstart line number the fold starts on
" v:foldend line number the fold ends on
" v:foldlevel fold level
set foldtext=MyFoldText()
function MyFoldText()
let line = getline(v:foldstart)
let output = substitute(line, '###', '', 'g')
return output
endfunction
" Regions
syn region todoFold keepend start=/^###/ end=/^###/me=s-1,he=s-1,re=s-1 fold contains=todoHeader
syn match todoHeader /^###.*$/ contained contains=todoHeaderItem,todoHeaderStart
syn match todoHeaderStart "###" contained
syn match todoHeaderItem /[^###]*$/ contained
hi link todoHeaderStart Comment
hi todoHeaderItem ctermfg=red guifg=red
syn sync fromstart
set foldmethod=syntax
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment