--
David Fishburn
Bee wrote:I thought of creating wordlists in files for, such as, changing case of application specific keywords.
Been there, done that.
The :s approach doesn't cope well with comments and quoted strings. Particularly, the SQL keywords "and" and "or" are common.
Using vim's abbreviations can work well, f.ex.
:abbr select SELECT
On several projects where the coding standards called for reserved words in upper case, I've used an awk script that knew about comments and quoted strings, processing character by character with a simple state machine. As an exercise I translated it to VimL but it was slower than piping to awk, if I recall correctly.
...
This plugin:
Allows you to search based on how vim highlights words on the screen.
I wrote it to solve this exact problem though the plugin is more general than this specific use case.
The defaults will do exactly this.
Basically when editing a SQL file (using my color scheme) Vim highlights SQL keywords are yellow (select, update, from, join, where, and, or, ...) based on your syntax file.
This plugin will allow you to search and replace on the syntax group. So you can say "find all the yellow words and replace them with &\U". That regex at the end was by memory so it is probably no quite right. But Vim will UPPER case what it just found.
I use this all the time since I like my SQL a certain way.
I also use SQLUtilities.vim (http://www.vim.org/scripts/script.php?script_id=492) to reformat (beautify) the SQL statement into a nice readable format.
HTH.
David
No comments:
Post a Comment