On Sat, 17 Mar 2012, Christian Brabandt wrote:

Hi Tim!

On Sa, 17 Mär 2012, Tim Chase wrote:

On 03/17/12 13:12, [email protected] wrote:
On Sun, Mar 18, 2012 at 1:27 AM, Tim Chase<[email protected]>  wrote:
 :autocmd BufWrite * 
%s/\c\<\(select\|insert\|update\|create\|where\|from\|**like\|group\_s\+by\|order\_s\+by\|having\)\>/\U&/g

Adjust for whatever SQL keywords you want to include.

There is a syntax file in vim which is sqlanywhere.vim, it will highlight a lot of keyword. So the smart way is to make uppercase for all of those keywords.

yes, there are a lot of SQL keywords, and optionally functions if you want to highlight those. It would be handy to have something like

 :autocmd BufWrite * exec '%s/\c\<\('.join(synkeywords('sqlKeyword'), 
'\|').'\)\>/\U&/g'

but I don't know of any "synkeywords()" sort of function.

:%s/\<\w\+\>/\=synIDattr(synID(line('.'),col('.'),1), 
'name')=~'sql\%(keyword\|operator\|statement\)'?toupper(submatch(0)):submatch(0)/g

Wow.  Really nice.

Part of the reason I kept running with my SynKeywords() function was that I didn't see a way around the fact that synID required a position as input.

The only things I can add to this are:

1. you should use =~? instead of =~ (since it's 'sqlKeyword', and =~ depends on the value of 'ignorecase').

2. (as mentioned in the other thread) use '/ge' instead of '/g'

--
Best,
Ben

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