Tidy()

command Tidy call Tidy()
" nmap <silent> <leader>ti :call Tidy( )<cr>
function Tidy( )
  let cmd = ''
  if &syntax == 'perl'
    let cmd = 'perltidy -q -st'
  elseif &syntax == 'php'
    let cmd = '~/bin/php_beautifier'
  elseif &syntax == 'javascript'
    let cmd = '~/bin/js -f ~/bin/js_tidy.js'
  elseif &syntax == 'html' || &syntax == 'xhtml'
    let cmd = '/opt/local/bin/tidy  -config ~/.tidyrc'
  endif

  if cmd == ''
    return
  endif

  execute ':%:!' . cmd
endf