Internet: Create clean w3 compliant html code with tidy integration in Vi(m)
If you want to stick to vim as you favorite (html) editor just like me I found the following tip to integrate tidy into vim to be able to check your html code if it clean and w3 compliant.
Add the following file type plugin for html files.
$ cat ~/.vim/ftplugin/html/tidy.vim
| ”””””””””””””””””””””””””””””””””””””””””””””” |
| ” Adrian’s vim filetype plugin for html tags “ |
| ”””””””””””””””””””””””””””””””””””””””””””””” |
| “ |
| ” Maintainer: Adrian Mayo |
| ” URL: http://www.mayo-family.com/vim/ftplugin/html/tidy.vim |
| ” MAIN URL: http://www.mayo-family.com/vim |
| “ |
| ” This file defines maps to call the html tidy program, see: |
| ” http://tidy.sourgeforge.net/ |
| “ |
| ” This file should be placed in ~/.vim/ftplugin/html/ on Unix systems |
| ” and will automatically be sourced for filetype = html. |
| “ |
| ” Map to check html and display error in a new window |
| “ |
| noremap \err :1<CR>yG :20new<CR>p :setfiletype html<CR> :%!tidy -i >/dev/null<CR> |
| ” Map to tidy html |
| “ |
| noremap \tidy :%!tidy -i -f /dev/null<CR> |
| ” END |
| “ |
The new commands are invoked by typing \err and \tidy in normal mode.
Posted by Administrator on Sunday, October 22, 2006

