Is it possible to have extensive custom functions, just for a single document?
It's true there's modelines, but you can only do one line with them, and for security reasons, they only do variables.
So, just put this in your ~/.vimrc:
au BufRead *
\ if filereadable(expand("%:p:h")."/.".expand("%:t").".vim")
\ | exe 'source '.expand("%:p:h")."/.".expand("%:t").".vim"
\ | endif
That way, when you edit foobar.html, it will load .foobar.html.vim if it exists.
Then in .foobar.html.vim, put:
command! Fix call Fix()
" fix problems that commonly occur in this document
function! Fix()
%s/foo/bar/
endfunction
Then you can run :Fix while editing, whenever desired.