sponsor Vim development Vim logo Vim Book Ad

sql.vim : SQL indent file for Sybase SQL Anywhere and Oracle

 script karma  Rating 14/13, Downloaded by 4863  Comments, bugs, improvements  Vim wiki

created by
David Fishburn
 
script type
indent
 
description
This indent file was created for Sybase SQL Anywhere using the Watcom SQL syntax.
It has also been tested against Oracle packages.

This will not work for Sybase ASE and Microsoft SQL Server which use Transact-SQL syntax.

indent/sqlanywere.vim version 1.5 is included in the Vim 7.3 release.
indent/sqlanywere.vim version 3.0 is included in the Vim 7.3 patches.

In preparation for Vim 7, this file has been renamed to sqlanywhere.vim, but will continue to work with Vim 6.  Simply rename it to sql.vim to keep the default behaviour.

Supports a wide variety of syntax including standard the standards: IF, LOOP, CASE.
But it will also support less used syntax like the EXCEPTION statement.


 
install details
Put <sqlanywhere.vim> into your .vim/indent or vimfiles/indent directory
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
sqlanywhere.vim 4.0 2021-10-12 7.0 David Fishburn Added b:undo_indent support.
sqlanywhere.vim 3.0 2012-12-07 7.0 David Fishburn Added a vim option cpo check.

Added the FOR keyword to SQLBlockStart to handle (Alec Tica):
    for i in 1..100 loop
      |<-- I expect to have indentation here
    end loop;
sqlanywhere.vim 1.5 2007-04-01 6.0 David Fishburn In Vim 7, OMNI SQL completion (:h sql-completion) allows you to complete SQL even when not editing a SQL file.  Most programming languages allow you to use SQL (.Net, Java, PHP, Ruby, Javascript, ...) you can set the filetype to SQL temporarily and flip it back (once).  After that, you can use OMNI SQL completion.  Doing this quick filetype switch while using the SQL Anywhere indent script reported an error indicating IsLineComment function already exists.  This corrects the problem by making these routines script functions instead of public.
sqlanywhere.vim 1.4 2005-09-14 6.0 David Fishburn Comments are handled much better in this version.  Also the indent level is determined using the shiftwidth setting.  In version 1.3, it used the indent level of the statement above which is generally not what you want.
sql.vim 1.3 2004-06-04 6.0 David Fishburn Extensive work has been done to make this work with Oracle PL/SQL syntax and Sybase ASA syntax.
sql.vim 1.1 2003-07-11 6.0 David Fishburn Better support for closing ).
CREATE TABLE T1
(
id INT
)   - This is indented correctly.

CREATE FUNCTION f_authenticate(
     IN @user_id INTEGER
    ,IN @password VARCHAR(16)
)   - This is indented correctly.


sql.vim 1.0 2002-11-24 6.0 David Fishburn Initial upload
ip used for rating: 23.20.220.59

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github