You see, the great thing about posting vim stuff here is that people (Smylers, Aristotle, etc.) immediately post corrections. I appreciate that :)
Problem: when in the MySQL client, you can type 'edit' and edit your last SQL statement (can I go back further? I thought so, but I can't recall how). However, I want my syntax highlighting, but the filetype isn't set. After a bit of testing, I found out that the filename is always /var/tmp/sql* (on my system). So the following addition to my .vimrc fixes this:
" this is for MySQL's 'edit' command while in the client au! BufRead,BufNewFile /var/tmp/sql* :call SetMySQL() function! SetMySQL() set ft=sql SQLSetType mysql endfunction
Re:Having problems with this?
Ovid on 2008-05-06T21:25:23
Yes, I should have pointed that out. Thanks.
When you set filetype
in an autocommand, it’s better to use the setf
command instead of set ft=
. And why not make it a one-liner?
au! BufRead,BufNewFile/var/tmp/sql* setf sql | SQLSetType mysql
Re:I hate to be so predictable ;-)
Ovid on 2008-05-07T08:16:10
I guess setf is better in this case (didn't know about it until you suggested it), but I had tried to make this a one-liner, but I was using &&. I didn't think to try the bar. Thanks.
Now to try and integrate SQL::Tidy
:)