Hi J.!
On Mi, 16 Sep 2009, J. Manuel Picaza wrote:
> I would like to substitute in a long script all ocurrences of
> \<select
> \|from\where\|etc\> except if those words are part of a string
> (maarked as string in the corresponding highlight). eg.:
>
> select chain from someTable where chain contains("%SeLeCt%FroM") ->
> SELECT chain FROM someTable WHERE chain CONTAINS("%SeLeCt%FroM")
>
> What is missing to :%s/\<select\|from\|where\|contains\>/\U&
I am not sure, if that works correctly, but I think something along
this should work:
:%s/\<select\|from\|where\|contains\>/\=(synIDattr(synID(line("."),
col("."), 0), "name") !~# 'String')?(toupper(submatch(0))):submatch(0)/g
That's all in one line. It works by checking in which Syntax group
each match is, and only if the match isn't in the sqlString Syntax
grouo, it replaces the match by its uppercase version, else it returns
the match. You might need to add additional Syntax names, if you would
like to have them excluded as well.
regards,
Christian
--
:wq!
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---