This is a vi syntax highlighting trick gmax
emailed to me. It changes the syntax highlighting for here documents and the
qq() and q() operators as long as braces {} are used to delimit them (that is the trick, you see). This example
'embeds' the MySQL highlighting scheme inside Perl code. Example.Find the perl.vim file that is being used by your version of vi, usually somewhere
in /usr/share/vim/Add this syntax to it:
syn include @Sql <sfile>:p:h/mysql.vim
syn region perlSQL start="qq{" end="}" contains=@Sql keepend
syn region perlSQL start="q{" end="}" contains=@Sql keepend
syn region perlSQL start="<<MYSQL" end="^MYSQL" contains=@Sql keepend
just before this line at the end of the file:let b:current_syntax = "perl"and save this file [mysql.vim] to the same directory
as the file you just edited (perl.vim).
Programing, Shell scripting, Windows, Linux. I'm using this as a repository for all those niggling little tasks that get done just often enough to be annoying, but maybe not often enough to commit to memory, and other things I feel like writing about.
Monday, January 28, 2008
Embedded vi Syntax Highlighting
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment