Benjamin R. Haskell wrote:
On Mon, 5 Jul 2010, Peng  Yu wrote:

No. You misunderstood me. I think that the vim can recognized the file
type by the suffix of the filename. There is no need to ":set
filetype=sql" explicitly.

But the default syntax highlight facility in vim doesn't reliably
syntax highlight SQL code embedded in a bash script. In the following
example, the SQL code after "*.txt" is not recognized correctly.
The syntax highlighting for PHP handles highlighting other languages
within heredocs.  Perhaps you can find a solution somewhere in there.

I believe it 'detects' the language via the heredoc label, though, so
you might need to use<<SQL
SQL
instead of<<EOF
EOF

See also:

:help :syn-include

As I see it, the script is being highlighted correctly from sh's viewpoint, as a heredoc is essentially just a long string.

What you appear to want is for the sh syntax script to recognize sqlite3 in the command and highlight the following heredoc using that other syntax. As Ben H pointed out, it is possible to use the syn-include approach to get what you want. I suggest writing a bit of extra syntax handling for this purpose and put it in your .vim/after/syntax/sh.vim file. Such a region would be recognized at the outset with sqlite3, etc. However, I don't think sh.vim is the place to try to recognize every possible language that heredoc strings might be using.

HTH,
Chip Campbell

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to