Capitalizing SQL keywords

51 views
Skip to first unread message

Sonny Chee

unread,
Sep 23, 2015, 3:09:51 PM9/23/15
to vim_use
Hey Guys,

I've defined a bunch of (SQL) keywords I would like to capitalize using "abbreviate". This works great when I am typing in fresh new file.

Is there a way to apply these abbreviations to an existing file?

Josef Fortier

unread,
Sep 23, 2015, 3:28:07 PM9/23/15
to vim_use

David Fishburn

unread,
Sep 23, 2015, 3:46:42 PM9/23/15
to vim_use
I created this plugin for this exact reason:


SrchRplcHiGrp.vim : Search and/or replace based on a syntax highlight group 

The default action will do exactly what you want.

Except I made it more general.
This gives you the ability to perform search and replace based on the syntax colouring of your Vim file.

Since SQL keywords are usually as a group (like keyword or statement) it can operate of those words of a given syntax group.


This one will also do it:
SQLUtilities : SQL utilities - Formatting, generate - columns lists, procedures for databases

It will also format your SQL queries.  
It has an option that while it reformats your SQL, it can change the case of the keywords.

HTH,
David


Josef Fortier

unread,
Sep 25, 2015, 7:48:45 PM9/25/15
to vim_use
On Wednesday, September 23, 2015 at 2:09:51 PM UTC-5, Sonny Chee wrote:

> I've defined a bunch of (SQL) keywords I would like to capitalize
> using "abbreviate".

It's not your question, but you might like this approach I put together:

https://github.com/fourjay/upsql-vim

It has a (potential) advantage over the abbreviate approach, in that it uses syntax to determine SQL keywords. The consequences are minor, but are real, notably that a) It works on mixed case b) it's source is the syntax file, which means no having to worry about maintaining the keyword list.

I'm the only user. The basic approach comes from this group (Christian Brandt post from a long time a go that I found through google). It's put together with the assumption that a user will use a plugin manager to run it (that's how I use it and how I expect many others do).

That said, David's work is wonderful. I use his plugins all the time. His sqlutil formatter works very well (and is quite configurable). I've used it more then once to make sense out of of some unformatted glob of SQL. Likewise dbext is pretty wonderful.

Sonny

unread,
Sep 29, 2015, 4:21:16 PM9/29/15
to vim...@googlegroups.com
Hey Guys,
 
Thanks for the multiple suggestions.  I particularly liked David Fishburn's suggestion; I am now motivated to learn Vimscript to hack his plugin to my particular formating fancy....


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

---
You received this message because you are subscribed to a topic in the Google Groups "vim_use" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/IRGHxgYbYCQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vim_use+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Sonny.
----------------------------------------------------------------------------
Be true to your work, your word, and your friend. Henry David Thoreau.

David Fishburn

unread,
Sep 29, 2015, 4:35:47 PM9/29/15
to vim_use
  
Thanks for the multiple suggestions.  I particularly liked David Fishburn's suggestion; I am now motivated to learn Vimscript to hack his plugin to my particular formating fancy....

The plugin is configurable (to a point), so feel free to start a dialogue on it.

David

Reply all
Reply to author
Forward
0 new messages