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.


#!/usr/bin/env bash

rm -f main.db
sqlite3 main.db <<EOF
create table test (ID1 integer, ID2 integer);
EOF

for f in xxx/*.txt;
do

geneid=`basename $f .txt`
echo $id

sqlite3 main.db <<EOF
create temp table dummy(value integer);
.import xxx/$id.txt dummy
insert into test (ID1, ID2) select '$id', value from dummy;
EOF

done

On Jul 4, 5:02 pm, Zoran Zaric <[email protected]> wrote:
> I hope I got your question right. You can force vim to use the
> highlighting for a special filetype by setting the filetype for the
> current buffer.
>
> :set filetype=sql
>
> did the correct highlighting of the sql-code for me.
>
> I hope this helps.
>
> Peng Yu schrieb:
>
> > Due to the fact that sqlite3 can not directly process a file using
> > shebang, I have to use the here document from bash for sqlite3 script.
> > But the syntax highlight is not correct. Does anybody have any fix to
> > the vim default for this kind of sqlite3 script embedded in bash here
> > document? Note that the complication is that environment variable can
> > be used in the here document, which can be enclosed in for loop.
>
> > $ cat main.sql
> > #!/usr/bin/env bash
>
> > rm -rf main.db
> > sqlite3 main.db <<EOF
>
> > .mode column
> > .headers on
> > .echo on
> > create table test (id integer primary key, value text);
> > insert into test (value) values('eenie');
> > insert into test (value) values('meenie');
> > insert into test (value) values('miny');
> > insert into test (value) values('mo');
> > insert into test (value) values('$SOME_ENV_VAR');
>
> > select * from test;
>
> > EOF

-- 
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