On 3/17/2012 11:33 AM, stardiviner wrote:
I want a vim script to convert SQL keyword(statement, clause, those highlig=
ht group in file) to be
converted to *uppercase* when I type command `:w` to save file.
And another way is when I am typing: `select`, then vim automatically chang=
e to `SELECT`. (this can
be done with abbreviate).

Use uppercase SQL keyword will improve the readability of sql code. That's =
why I want this script.

If you know a script can do this, or you will create a new script to do thi=
s, please tell me.
(I do not know Vimscript, so I ask this script here).

Of course there is a Vim script to do this!

The script uses many of the suggestions already made within this thread.

It also fully supports the 3 different types of visual modes to select a range of text. You can use SRChooseHiGrp or SRChooseHiGrp! to automatically select the syntax group you are interested in. SRSearch allows you to search for text which belongs to a certain syntax group.
SRHiGrp - Search and Replace Highlight Group (does the action you want)

I originally wrote this plugin since if Vim already knows how to highlight what I want on the screen, let me perform some operations on that highlighted text.

SrchRplcHiGrp.vim : Search and/or replace based on a syntax highlight group
http://www.vim.org/scripts/script.php?script_id=848

You can perform any action you want, does not have to be as simple as UPPER casing text. Though the _default_ action for the script which prompts you is to do _exactly what you want_, UPPER case the text.


Along the same vein is:

SyntaxComplete     OMNI Completion based on the current syntax highlights
http://www.vim.org/scripts/script.php?script_id=3172


I do a lot of SQL work, so almost all of my plugins are centered around it:

vim73/ftplugin/sql.vim
vim73/ftplugin/sqlanywhere.vim
vim73/indent/sqlanywhere.vim
vim73/syntax/sqlanywhere.vim

dbext.vim : Provides database access to many dbms (Oracle, Sybase, Microsoft, MySQL, DBI,..)
http://www.vim.org/scripts/script.php?script_id=356

SQLComplete
http://www.vim.org/scripts/script.php?script_id=1572

SQLUtilities SQL utilities - Formatting, generate - columns lists, procedures for databases
http://www.vim.org/scripts/script.php?script_id=492

This plugin will also do what you want (change the case on SQL keywords) though it does not use Vim's syntax groups to do it. It will do a lot for you, the main reason I wrote it was to (re)format SQL statements, then just added to it.

Have fun.

Dave



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