For the most part Vim just works. For example, on Ubuntu if you
apt-get install vim
then it comes with syntax highlighting for Perl scripts (ending in .pl), Perl modules (ending in .pm) and HTML files (ending in .html). It also comes with brace matching for the Perl code, but no <html> tag matching </html>. This is a real pain if you're trying to make sense of a large HTML file in Vim.
HTML tag matching
1. Find plugin/matchit.vim and copy it into your personal vim plugin directory ~/.vim/plugin (creating it if it's not already there)
mkdir -p ~/.vim/plugin
cp `locate plugin/matchit.vim` ~/.vim/plugin
2. Add this line to your Vim config file ~/.vimrc
echo filetype plugin on >> .vimrc
Then voilĂ ! With Vim you can now jump between matching tags like <html> and </html> using the % key.
Template Toolkit syntax highlighting and tag matching
Of course if you're working on a Perl Template Toolkit we're back to square one because you have HTML'ish files called something like:
foo.html.tt
At this point you just need to add the following line to your ~/.vimrc file
echo au BufRead,BufNewFile *.tt setfiletype html >> ~/.vimrc
and once again you have HTML highlighting and tag matching just like an HTML file (although the TT delimiters [% %] are still ignored by Vim).
Enjoy!
If you use bcvi then your Vim customisations only need to live on your laptop/workstation.
ReplyDeletehttp://sshmenu.sourceforge.net/articles/bcvi/
better yet for Template Toolkit, use the vim-perl syntax files:
ReplyDeletehttps://github.com/vim-perl/vim-perl/blob/master/syntax/
There is even a syntax file for type "tt2html" which is html with template toolkit support. Best of both worlds.