aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc/ft_sql.txt
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/doc/ft_sql.txt')
-rw-r--r--runtime/doc/ft_sql.txt79
1 files changed, 44 insertions, 35 deletions
diff --git a/runtime/doc/ft_sql.txt b/runtime/doc/ft_sql.txt
index 335faf266e..21a244e67a 100644
--- a/runtime/doc/ft_sql.txt
+++ b/runtime/doc/ft_sql.txt
@@ -37,9 +37,10 @@ The SQL ftplugin provides a number of options to assist with file
navigation.
+------------------------------------------------------------------------------
1.1 Matchit *sql-matchit*
------------
-The matchit plugin (http://www.vim.org/scripts/script.php?script_id=39)
+
+The matchit plugin (https://www.vim.org/scripts/script.php?script_id=39)
provides many additional features and can be customized for different
languages. The matchit plugin is configured by defining a local
buffer variable, b:match_words. Pressing the % key while on various
@@ -85,8 +86,9 @@ The following keywords are supported: >
returns
+------------------------------------------------------------------------------
1.2 Text Object Motions *sql-object-motions*
------------------------
+
Vim has a number of predefined keys for working with text |object-motions|.
This filetype plugin attempts to translate these keys to maps which make sense
for the SQL language.
@@ -99,8 +101,9 @@ file): >
[] move backwards to the previous 'end'
+------------------------------------------------------------------------------
1.3 Predefined Object Motions *sql-predefined-objects*
------------------------------
+
Most relational databases support various standard features, tables, indices,
triggers and stored procedures. Each vendor also has a variety of proprietary
objects. The next set of maps have been created to help move between these
@@ -166,8 +169,9 @@ with comments: >
+------------------------------------------------------------------------------
1.4 Macros *sql-macros*
-----------
+
Vim's feature to find macro definitions, |'define'|, is supported using this
regular expression: >
\c\<\(VARIABLE\|DECLARE\|IN\|OUT\|INOUT\)\>
@@ -230,8 +234,9 @@ The majority of people work with only one vendor's database product, it would
be nice to specify a default in your |init.vim|.
+------------------------------------------------------------------------------
2.1 SQLSetType *sqlsettype* *SQLSetType*
---------------
+
For the people that work with many different databases, it is nice to be
able to flip between the various vendors rules (indent, syntax) on a per
buffer basis, at any time. The ftplugin/sql.vim file defines this function: >
@@ -244,7 +249,7 @@ key to complete the optional parameter.
After typing the function name and a space, you can use the completion to
supply a parameter. The function takes the name of the Vim script you want to
source. Using the |cmdline-completion| feature, the SQLSetType function will
-search the |'runtimepath'| for all Vim scripts with a name containing 'sql'.
+search the |'runtimepath'| for all Vim scripts with a name containing "sql".
This takes the guess work out of the spelling of the names. The following are
examples: >
:SQLSetType
@@ -259,8 +264,9 @@ of available Vim script names: >
:SQL<Tab><space><Tab>
+------------------------------------------------------------------------------
2.2 SQLGetType *sqlgettype* *SQLGetType*
---------------
+
At anytime you can determine which SQL dialect you are using by calling the
SQLGetType command. The ftplugin/sql.vim file defines this function: >
SQLGetType
@@ -269,8 +275,9 @@ This will echo: >
Current SQL dialect in use:sqlanywhere
+------------------------------------------------------------------------------
2.3 SQL Dialect Default *sql-type-default*
------------------------
+
As mentioned earlier, the default syntax rules for Vim is based on Oracle
(PL/SQL). You can override this default by placing one of the following in
your |init.vim|: >
@@ -296,7 +303,7 @@ exist.
3. Adding new SQL Dialects *sql-adding-dialects*
If you begin working with a SQL dialect which does not have any customizations
-available with the default Vim distribution you can check http://www.vim.org
+available with the default Vim distribution you can check https://www.vim.org
to see if any customization currently exist. If not, you can begin by cloning
an existing script. Read |filetype-plugins| for more details.
@@ -325,8 +332,9 @@ highlight rules. The dynamic mode populates the popups with data retrieved
directly from a database. This includes, table lists, column lists,
procedures names and more.
+------------------------------------------------------------------------------
4.1 Static Mode *sql-completion-static*
----------------
+
The static popups created contain items defined by the active syntax rules
while editing a file with a filetype of SQL. The plugin defines (by default)
various maps to help the user refine the list of items to be displayed.
@@ -399,11 +407,12 @@ Here are some examples of the entries which are pulled from the syntax files: >
- Integer, Char, Varchar, Date, DateTime, Timestamp, ...
+------------------------------------------------------------------------------
4.2 Dynamic Mode *sql-completion-dynamic*
-----------------
+
Dynamic mode populates the popups with data directly from a database. In
order for the dynamic feature to be enabled you must have the dbext.vim
-plugin installed, (http://vim.sourceforge.net/script.php?script_id=356).
+plugin installed, (https://vim.sourceforge.net/script.php?script_id=356).
Dynamic mode is used by several features of the SQL completion plugin.
After installing the dbext plugin see the dbext-tutorial for additional
@@ -448,8 +457,8 @@ necessary to clear the plugins cache. The default map for this is: >
imap <buffer> <C-C>R <C-\><C-O>:call sqlcomplete#Map('ResetCache')<CR><C-X><C-O>
+------------------------------------------------------------------------------
4.3 SQL Tutorial *sql-completion-tutorial*
-----------------
This tutorial is designed to take you through the common features of the SQL
completion plugin so that: >
@@ -462,8 +471,8 @@ First, create a new buffer: >
:e tutorial.sql
-Static features
----------------
+Static features ~
+
To take you through the various lists, simply enter insert mode, hit:
<C-C>s (show SQL statements)
At this point, you can page down through the list until you find "select".
@@ -484,10 +493,10 @@ depending on the syntax file you are using. The SQL Anywhere syntax file
DECLARE customer_id <C-C>T <-- Choose a type from the list
-Dynamic features
-----------------
+Dynamic features ~
+
To take advantage of the dynamic features you must first install the
-dbext.vim plugin (http://vim.sourceforge.net/script.php?script_id=356). It
+dbext.vim plugin (https://vim.sourceforge.net/script.php?script_id=356). It
also comes with a tutorial. From the SQL completion plugin's perspective,
the main feature dbext provides is a connection to a database. dbext
connection profiles are the most efficient mechanism to define connection
@@ -597,8 +606,8 @@ Similar to the table list, <C-C>v, will display a list of views in the
database.
+------------------------------------------------------------------------------
4.4 Completion Customization *sql-completion-customization*
-----------------------------
The SQL completion plugin can be customized through various options set in
your |init.vim|: >
@@ -657,14 +666,14 @@ your |init.vim|: >
option.
>
+------------------------------------------------------------------------------
4.5 SQL Maps *sql-completion-maps*
-------------
The default SQL maps have been described in other sections of this document in
greater detail. Here is a list of the maps with a brief description of each.
-Static Maps
------------
+Static Maps ~
+
These are maps which use populate the completion list using Vim's syntax
highlighting rules. >
<C-C>a
@@ -680,8 +689,8 @@ highlighting rules. >
<C-C>s
< - Displays all SQL syntax items defined as 'sqlStatement'. >
-Dynamic Maps
-------------
+Dynamic Maps ~
+
These are maps which use populate the completion list using the dbext.vim
plugin. >
<C-C>t
@@ -713,8 +722,8 @@ plugin. >
< - This maps removes all cached items and forces the SQL completion
to regenerate the list of items.
-Customizing Maps
-----------------
+Customizing Maps ~
+
You can create as many additional key maps as you like. Generally, the maps
will be specifying different syntax highlight groups.
@@ -733,8 +742,8 @@ chosen since it will work on both Windows and *nix platforms. On the windows
platform you can also use <C-Space> or ALT keys.
+------------------------------------------------------------------------------
4.6 Using with other filetypes *sql-completion-filetypes*
-------------------------------
Many times SQL can be used with different filetypes. For example Perl, Java,
PHP, Javascript can all interact with a database. Often you need both the SQL
@@ -746,8 +755,8 @@ This can be enabled easily with the following steps (assuming a Perl file): >
2. :set filetype=sql
3. :set ft=perl
-Step 1
-------
+Step 1 ~
+
Begins by editing a Perl file. Vim automatically sets the filetype to
"perl". By default, Vim runs the appropriate filetype file
ftplugin/perl.vim. If you are using the syntax completion plugin by following
@@ -755,9 +764,9 @@ the directions at |ft-syntax-omni| then the |'omnifunc'| option has been set to
"syntax#Complete". Pressing <C-X><C-O> will display the omni popup containing
the syntax items for Perl.
-Step 2
-------
-Manually setting the filetype to 'sql' will also fire the appropriate filetype
+Step 2 ~
+
+Manually setting the filetype to "sql" will also fire the appropriate filetype
files ftplugin/sql.vim. This file will define a number of buffer specific
maps for SQL completion, see |sql-completion-maps|. Now these maps have
been created and the SQL completion plugin has been initialized. All SQL
@@ -767,8 +776,8 @@ begin with <C-C>, the maps will toggle the |'omnifunc'| when in use. So you
can use <C-X><C-O> to continue using the completion for Perl (using the syntax
completion plugin) and <C-C> to use the SQL completion features.
-Step 3
-------
+Step 3 ~
+
Setting the filetype back to Perl sets all the usual "perl" related items back
as they were.