codekingpro/portable-devtools
114k
1*ft_sql.txt* For Vim version 9.2. Last change: 2026 Feb 142 3by David Fishburn4 5This is a filetype plugin to work with SQL files.6 7The Structured Query Language (SQL) is a standard which specifies statements8that allow a user to interact with a relational database. Vim includes9features for navigation, indentation and syntax highlighting.10 111. Navigation |sql-navigation|12 1.1 Matchit |sql-matchit|13 1.2 Text Object Motions |sql-object-motions|14 1.3 Predefined Object Motions |sql-predefined-objects|15 1.4 Macros |sql-macros|162. SQL Dialects |sql-dialects|17 2.1 SQLSetType |SQLSetType|18 2.2 SQLGetType |SQLGetType|19 2.3 SQL Dialect Default |sql-type-default|203. Adding new SQL Dialects |sql-adding-dialects|214. OMNI SQL Completion |sql-completion|22 4.1 Static mode |sql-completion-static|23 4.2 Dynamic mode |sql-completion-dynamic|24 4.3 Tutorial |sql-completion-tutorial|25 4.3.1 Complete Tables |sql-completion-tables|26 4.3.2 Complete Columns |sql-completion-columns|27 4.3.3 Complete Procedures |sql-completion-procedures|28 4.3.4 Complete Views |sql-completion-views|29 4.4 Completion Customization |sql-completion-customization|30 4.5 SQL Maps |sql-completion-maps|31 4.6 Using with other filetypes |sql-completion-filetypes|32 33==============================================================================341. Navigation *sql-navigation*35 36The SQL ftplugin provides a number of options to assist with file37navigation.38 39 401.1 Matchit *sql-matchit*41-----------42The matchit plugin (http://www.vim.org/scripts/script.php?script_id=39)43provides many additional features and can be customized for different44languages. The matchit plugin is configured by defining a local45buffer variable, b:match_words. Pressing the % key while on various46keywords will move the cursor to its match. For example, if the cursor47is on an "if", pressing % will cycle between the "else", "elseif" and48"end if" keywords.49 50The following keywords are supported: >51 if52 elseif | elsif53 else [if]54 end if55 56 [while condition] loop57 leave58 break59 continue60 exit61 end loop62 63 for64 leave65 break66 continue67 exit68 end loop69 70 do71 statements72 doend73 74 case75 when76 when77 default78 end case79 80 merge81 when not matched82 when matched83 84 create[ or replace] procedure|function|event85 returns86 87 881.2 Text Object Motions *sql-object-motions*89-----------------------90Vim has a number of predefined keys for working with text |object-motions|.91This filetype plugin attempts to translate these keys to maps which make sense92for the SQL language.93 94The following |Normal| mode and |Visual| mode maps exist (when you edit a SQL95file): >96 ]] move forward to the next 'begin'97 [[ move backwards to the previous 'begin'98 ][ move forward to the next 'end'99 [] move backwards to the previous 'end'100 101 1021.3 Predefined Object Motions *sql-predefined-objects*103-----------------------------104Most relational databases support various standard features, tables, indices,105triggers and stored procedures. Each vendor also has a variety of proprietary106objects. The next set of maps have been created to help move between these107objects. Depends on which database vendor you are using, the list of objects108must be configurable. The filetype plugin attempts to define many of the109standard objects, plus many additional ones. In order to make this as110flexible as possible, you can override the list of objects from within your111|vimrc| with the following: >112 let g:ftplugin_sql_objects = 'function,procedure,event,table,trigger' ..113 \ ',schema,service,publication,database,datatype,domain' ..114 \ ',index,subscription,synchronization,view,variable'115 116The following |Normal| mode and |Visual| mode maps have been created which use117the above list: >118 ]} move forward to the next 'create <object name>'119 [{ move backward to the previous 'create <object name>'120 121Repeatedly pressing ]} will cycle through each of these create statements: >122 create table t1 (123 ...124 );125 126 create procedure p1127 begin128 ...129 end;130 131 create index i1 on t1 (c1);132 133The default setting for g:ftplugin_sql_objects is: >134 let g:ftplugin_sql_objects = 'function,procedure,event,' ..135 \ '\\(existing\\\\|global\\s\\+temporary\\s\\+\\)\\\{,1}' ..136 \ 'table,trigger' ..137 \ ',schema,service,publication,database,datatype,domain' ..138 \ ',index,subscription,synchronization,view,variable'139 140The above will also handle these cases: >141 create table t1 (142 ...143 );144 create existing table t2 (145 ...146 );147 create global temporary table t3 (148 ...149 );150 151By default, the ftplugin only searches for CREATE statements. You can also152override this via your |vimrc| with the following: >153 let g:ftplugin_sql_statements = 'create,alter'154 155The filetype plugin defines three types of comments: >156 1. --157 2. //158 3. /*159 *160 */161 162The following |Normal| mode and |Visual| mode maps have been created to work163with comments: >164 ]" move forward to the beginning of a comment165 [" move forward to the end of a comment166 167 168 1691.4 Macros *sql-macros*170----------171Vim's feature to find macro definitions, 'define', is supported using this172regular expression: >173 \c\<\(VARIABLE\|DECLARE\|IN\|OUT\|INOUT\)\>174 175This addresses the following code: >176 CREATE VARIABLE myVar1 INTEGER;177 178 CREATE PROCEDURE sp_test(179 IN myVar2 INTEGER,180 OUT myVar3 CHAR(30),181 INOUT myVar4 NUMERIC(20,0)182 )183 BEGIN184 DECLARE myVar5 INTEGER;185 186 SELECT c1, c2, c3187 INTO myVar2, myVar3, myVar4188 FROM T1189 WHERE c4 = myVar1;190 END;191 192Place your cursor on "myVar1" on this line: >193 WHERE c4 = myVar1;194 ^195 196Press any of the following keys: >197 [d198 [D199 [CTRL-D200 201 202==============================================================================2032. SQL Dialects *sql-dialects* *sql-types*204 *sybase* *TSQL* *Transact-SQL*205 *sqlanywhere*206 *oracle* *plsql* *sqlj*207 *sqlserver*208 *mysql* *postgresql* *psql*209 *informix*210 211All relational databases support SQL. There is a portion of SQL that is212portable across vendors (ex. CREATE TABLE, CREATE INDEX), but there is a213great deal of vendor specific extensions to SQL. Oracle supports the214"CREATE OR REPLACE" syntax, column defaults specified in the CREATE TABLE215statement and the procedural language (for stored procedures and triggers).216 217The default Vim distribution ships with syntax highlighting based on Oracle's218PL/SQL. The default SQL indent script works for Oracle and SQL Anywhere.219The default filetype plugin works for all vendors and should remain vendor220neutral, but extendable.221 222Vim currently has support for a variety of different vendors, currently this223is via syntax scripts. Unfortunately, to flip between different syntax rules224you must either create:225 1. New filetypes226 2. Custom autocmds227 3. Manual steps / commands228 229The majority of people work with only one vendor's database product, it would230be nice to specify a default in your |vimrc|.231 232 2332.1 SQLSetType *sqlsettype* *SQLSetType*234--------------235For the people that work with many different databases, it is nice to be236able to flip between the various vendors rules (indent, syntax) on a per237buffer basis, at any time. The ftplugin/sql.vim file defines this function: >238 SQLSetType239 240Executing this function without any parameters will set the indent and syntax241scripts back to their defaults, see |sql-type-default|. If you have turned242off Vi's compatibility mode, 'compatible', you can use the <Tab> key to243complete the optional parameter.244 245After typing the function name and a space, you can use the completion to246supply a parameter. The function takes the name of the Vim script you want to247source. Using the |cmdline-completion| feature, the SQLSetType function will248search the 'runtimepath' for all Vim scripts with a name containing 'sql'.249This takes the guess work out of the spelling of the names. The following are250examples: >251 :SQLSetType252 :SQLSetType sqloracle253 :SQLSetType sqlanywhere254 :SQLSetType sqlinformix255 :SQLSetType mysql256 257The easiest approach is to the use <Tab> character which will first complete258the command name (SQLSetType), after a space and another <Tab>, display a list259of available Vim script names: >260 :SQL<Tab><space><Tab>261 262 2632.2 SQLGetType *sqlgettype* *SQLGetType*264--------------265At anytime you can determine which SQL dialect you are using by calling the266SQLGetType command. The ftplugin/sql.vim file defines this function: >267 SQLGetType268 269This will echo: >270 Current SQL dialect in use:sqlanywhere271 272 2732.3 SQL Dialect Default *sql-type-default*274-----------------------275As mentioned earlier, the default syntax rules for Vim is based on Oracle276(PL/SQL). You can override this default by placing one of the following in277your |vimrc|: >278 let g:sql_type_default = 'sqlanywhere'279 let g:sql_type_default = 'sqlinformix'280 let g:sql_type_default = 'mysql'281 282If you added the following to your |vimrc|: >283 let g:sql_type_default = 'sqlinformix'284 285The next time edit a SQL file the following scripts will be automatically286loaded by Vim: >287 ftplugin/sql.vim288 syntax/sqlinformix.vim289 indent/sql.vim290>291Notice indent/sqlinformix.sql was not loaded. There is no indent file292for Informix, Vim loads the default files if the specified files does not293exist.294 295 296==============================================================================2973. Adding new SQL Dialects *sql-adding-dialects*298 299If you begin working with a SQL dialect which does not have any customizations300available with the default Vim distribution you can check http://www.vim.org301to see if any customization currently exist. If not, you can begin by cloning302an existing script. Read |filetype-plugins| for more details.303 304To help identify these scripts, try to create the files with a "sql" prefix.305If you decide you wish to create customizations for the SQLite database, you306can create any of the following: >307 Unix308 ~/.vim/syntax/sqlite.vim309 ~/.vim/indent/sqlite.vim310 Windows311 $VIM/vimfiles/syntax/sqlite.vim312 $VIM/vimfiles/indent/sqlite.vim313 314No changes are necessary to the SQLSetType function. It will automatically315pick up the new SQL files and load them when you issue the SQLSetType command.316 317 318==============================================================================3194. OMNI SQL Completion *sql-completion*320 *omni-sql-completion*321 322Vim 7 includes a code completion interface and functions which allows plugin323developers to build in code completion for any language. Vim 7 includes324code completion for the SQL language.325 326There are two modes to the SQL completion plugin, static and dynamic. The327static mode populates the popups with the data generated from current syntax328highlight rules. The dynamic mode populates the popups with data retrieved329directly from a database. This includes, table lists, column lists,330procedures names and more.331 3324.1 Static Mode *sql-completion-static*333---------------334The static popups created contain items defined by the active syntax rules335while editing a file with a filetype of SQL. The plugin defines (by default)336various maps to help the user refine the list of items to be displayed.337The defaults static maps are: >338 imap <buffer> <C-C>a <C-\><C-O>:call sqlcomplete#Map('syntax')<CR><C-X><C-O>339 imap <buffer> <C-C>k <C-\><C-O>:call sqlcomplete#Map('sqlKeyword')<CR><C-X><C-O>340 imap <buffer> <C-C>f <C-\><C-O>:call sqlcomplete#Map('sqlFunction')<CR><C-X><C-O>341 imap <buffer> <C-C>o <C-\><C-O>:call sqlcomplete#Map('sqlOption')<CR><C-X><C-O>342 imap <buffer> <C-C>T <C-\><C-O>:call sqlcomplete#Map('sqlType')<CR><C-X><C-O>343 imap <buffer> <C-C>s <C-\><C-O>:call sqlcomplete#Map('sqlStatement')<CR><C-X><C-O>344 345The use of "<C-C>" can be user chosen by using the following in your |.vimrc|346as it may not work properly on all platforms: >347 let g:ftplugin_sql_omni_key = '<C-C>'348>349The static maps (which are based on the syntax highlight groups) follow this350format: >351 imap <buffer> <C-C>k <C-\><C-O>:call sqlcomplete#Map('sqlKeyword')<CR><C-X><C-O>352 imap <buffer> <C-C>k <C-\><C-O>:call sqlcomplete#Map('sqlKeyword\w*')<CR><C-X><C-O>353 354This command breaks down as: >355 imap - Create an insert map356 <buffer> - Only for this buffer357 <C-C>k - Your choice of key map358 <C-\><C-O> - Execute one command, return to Insert mode359 :call sqlcomplete#Map( - Allows the SQL completion plugin to perform some360 housekeeping functions to allow it to be used in361 conjunction with other completion plugins.362 Indicate which item you want the SQL completion363 plugin to complete.364 In this case we are asking the plugin to display365 items from the syntax highlight group366 'sqlKeyword'.367 You can view a list of highlight group names to368 choose from by executing the369 :syntax list370 command while editing a SQL file.371 'sqlKeyword' - Display the items for the sqlKeyword highlight372 group373 'sqlKeyword\w*' - A second option available with Vim 7.4 which374 uses a regular expression to determine which375 syntax groups to use376 )<CR> - Execute the :let command377 <C-X><C-O> - Trigger the standard omni completion key stroke.378 Passing in 'sqlKeyword' instructs the SQL379 completion plugin to populate the popup with380 items from the sqlKeyword highlight group. The381 plugin will also cache this result until Vim is382 restarted. The syntax list is retrieved using383 the syntaxcomplete plugin.384 385Using the 'syntax' keyword is a special case. This instructs the386syntaxcomplete plugin to retrieve all syntax items. So this will effectively387work for any of Vim's SQL syntax files. At the time of writing this includes38810 different syntax files for the different dialects of SQL (see section 3389above, |sql-dialects|).390 391Here are some examples of the entries which are pulled from the syntax files: >392 All393 - Contains the contents of all syntax highlight groups394 Statements395 - Select, Insert, Update, Delete, Create, Alter, ...396 Functions397 - Min, Max, Trim, Round, Date, ...398 Keywords399 - Index, Database, Having, Group, With400 Options401 - Isolation_level, On_error, Qualify_owners, Fire_triggers, ...402 Types403 - Integer, Char, Varchar, Date, DateTime, Timestamp, ...404 405 4064.2 Dynamic Mode *sql-completion-dynamic*407----------------408Dynamic mode populates the popups with data directly from a database. In409order for the dynamic feature to be enabled you must have the dbext.vim410plugin installed, (https://www.vim.org/scripts/script.php?script_id=356).411 412Dynamic mode is used by several features of the SQL completion plugin.413After installing the dbext plugin see the dbext-tutorial for additional414configuration and usage. The dbext plugin allows the SQL completion plugin415to display a list of tables, procedures, views and columns. >416 Table List417 - All tables for all schema owners418 Procedure List419 - All stored procedures for all schema owners420 View List421 - All stored procedures for all schema owners422 Column List423 - For the selected table, the columns that are part of the table424 425To enable the popup, while in INSERT mode, use the following key combinations426for each group (where <C-C> means hold the CTRL key down while pressing427the space bar):428 Table List - <C-C>t429 - <C-X><C-O> (the default map assumes tables)430 Stored Procedure List - <C-C>p431 View List - <C-C>v432 Column List - <C-C>c433 434 Drilling In / Out - When viewing a popup window displaying the list435 of tables, you can press <Right>, this will436 replace the table currently highlighted with437 the column list for that table.438 - When viewing a popup window displaying the list439 of columns, you can press <Left>, this will440 replace the column list with the list of tables.441 - This allows you to quickly drill down into a442 table to view its columns and back again.443 - <Right> and <Left> can also be chosen via444 your |.vimrc| >445 let g:ftplugin_sql_omni_key_right = '<Right>'446 let g:ftplugin_sql_omni_key_left = '<Left>'447 448The SQL completion plugin caches various lists that are displayed in449the popup window. This makes the re-displaying of these lists very450fast. If new tables or columns are added to the database it may become451necessary to clear the plugins cache. The default map for this is: >452 imap <buffer> <C-C>R <C-\><C-O>:call sqlcomplete#Map('ResetCache')<CR><C-X><C-O>453 454 4554.3 SQL Tutorial *sql-completion-tutorial*456----------------457 458This tutorial is designed to take you through the common features of the SQL459completion plugin so that: >460 a) You gain familiarity with the plugin461 b) You are introduced to some of the more common features462 c) Show how to customize it to your preferences463 d) Demonstrate "Best of Use" of the plugin (easiest way to configure).464 465First, create a new buffer: >466 :e tutorial.sql467 468 469Static features470---------------471To take you through the various lists, simply enter insert mode, hit:472 <C-C>s (show SQL statements)473At this point, you can page down through the list until you find "select".474If you are familiar with the item you are looking for, for example you know475the statement begins with the letter "s". You can type ahead (without the476quotes) "se" then press:477 <C-Space>t478Assuming "select" is highlighted in the popup list press <Enter> to choose479the entry. Now type:480 * fr<C-C>a (show all syntax items)481choose "from" from the popup list.482 483When writing stored procedures using the "type" list is useful. It contains484a list of all the database supported types. This may or may not be true485depending on the syntax file you are using. The SQL Anywhere syntax file486(sqlanywhere.vim) has support for this: >487 BEGIN488 DECLARE customer_id <C-C>T <-- Choose a type from the list489 490 491Dynamic features492----------------493To take advantage of the dynamic features you must first install the494dbext.vim plugin (https://www.vim.org/scripts/script.php?script_id=356). It495also comes with a tutorial. From the SQL completion plugin's perspective,496the main feature dbext provides is a connection to a database. dbext497connection profiles are the most efficient mechanism to define connection498information. Once connections have been setup, the SQL completion plugin499uses the features of dbext in the background to populate the popups.500 501What follows assumes dbext.vim has been correctly configured, a simple test502is to run the command, :DBListTable. If a list of tables is shown, you know503dbext.vim is working as expected. If not, please consult the dbext.txt504documentation.505 506Assuming you have followed the dbext-tutorial you can press <C-C>t to507display a list of tables. There is a delay while dbext is creating the table508list. After the list is displayed press <C-W>. This will remove both the509popup window and the table name already chosen when the list became active.510 511 4.3.1 Table Completion: *sql-completion-tables*512 513Press <C-C>t to display a list of tables from within the database you514have connected via the dbext plugin.515NOTE: All of the SQL completion popups support typing a prefix before pressing516the key map. This will limit the contents of the popup window to just items517beginning with those characters.518 519 4.3.2 Column Completion: *sql-completion-columns*520 521The SQL completion plugin can also display a list of columns for particular522tables. The column completion is triggered via <C-C>c.523 524NOTE: The following example uses <Right> to trigger a column list while525 the popup window is active.526 527Example of using column completion:528 - Press <C-C>t again to display the list of tables.529 - When the list is displayed in the completion window, press <Right>,530 this will replace the list of tables, with a list of columns for the531 table highlighted (after the same short delay).532 - If you press <Left>, this will again replace the column list with the533 list of tables. This allows you to drill into tables and column lists534 very quickly.535 - Press <Right> again while the same table is highlighted. You will536 notice there is no delay since the column list has been cached. If you537 change the schema of a cached table you can press <C-C>R, which538 clears the SQL completion cache.539 - NOTE: <Right> and <Left> have been designed to work while the540 completion window is active. If the completion popup window is541 not active, a normal <Right> or <Left> will be executed.542 543Let's look at how we can build a SQL statement dynamically. A select statement544requires a list of columns. There are two ways to build a column list using545the SQL completion plugin. >546 One column at a time:547< 1. After typing SELECT press <C-C>t to display a list of tables.548 2. Choose a table from the list.549 3. Press <Right> to display a list of columns.550 4. Choose the column from the list and press enter.551 5. Enter a "," and press <C-C>c. Generating a column list552 generally requires having the cursor on a table name. The plugin553 uses this name to determine what table to retrieve the column list.554 In this step, since we are pressing <C-C>c without the cursor555 on a table name the column list displayed will be for the previous556 table. Choose a different column and move on.557 6. Repeat step 5 as often as necessary. >558 All columns for a table:559< 1. After typing SELECT press <C-C>t to display a list of tables.560 2. Highlight the table you need the column list for.561 3. Press <Enter> to choose the table from the list.562 4. Press <C-C>l to request a comma-separated list of all columns563 for this table.564 5. Based on the table name chosen in step 3, the plugin attempts to565 decide on a reasonable table alias. You are then prompted to566 either accept of change the alias. Press OK.567 6. The table name is replaced with the column list of the table is568 replaced with the comma separate list of columns with the alias569 prepended to each of the columns.570 7. Step 3 and 4 can be replaced by pressing <C-C>L, which has571 a <C-Y> embedded in the map to choose the currently highlighted572 table in the list.573 574There is a special provision when writing select statements. Consider the575following statement: >576 select *577 from customer c,578 contact cn,579 department as dp,580 employee e,581 site_options so582 where c.583 584In INSERT mode after typing the final "c." which is an alias for the585"customer" table, you can press either <C-C>c or <C-X><C-O>. This will586popup a list of columns for the customer table. It does this by looking back587to the beginning of the select statement and finding a list of the tables588specified in the FROM clause. In this case it notes that in the string589"customer c", "c" is an alias for the customer table. The optional "AS"590keyword is also supported, "customer AS c".591 592 593 4.3.3 Procedure Completion: *sql-completion-procedures*594 595Similar to the table list, <C-C>p, will display a list of stored596procedures stored within the database.597 598 4.3.4 View Completion: *sql-completion-views*599 600Similar to the table list, <C-C>v, will display a list of views in the601database.602 603 6044.4 Completion Customization *sql-completion-customization*605----------------------------606 607The SQL completion plugin can be customized through various options set in608your |vimrc|: >609 omni_sql_no_default_maps610< - Default: This variable is not defined611 - If this variable is defined, no maps are created for OMNI612 completion. See |sql-completion-maps| for further discussion.613>614 omni_sql_use_tbl_alias615< - Default: a616 - This setting is only used when generating a comma-separated617 column list. By default the map is <C-C>l. When generating618 a column list, an alias can be prepended to the beginning of each619 column, for example: e.emp_id, e.emp_name. This option has three620 settings: >621 n - do not use an alias622 d - use the default (calculated) alias623 a - ask to confirm the alias name624<625 An alias is determined following a few rules:626 1. If the table name has an '_', then use it as a separator: >627 MY_TABLE_NAME --> MTN628 my_table_name --> mtn629 My_table_NAME --> MtN630< 2. If the table name does NOT contain an '_', but DOES use631 mixed case then the case is used as a separator: >632 MyTableName --> MTN633< 3. If the table name does NOT contain an '_', and does NOT634 use mixed case then the first letter of the table is used: >635 mytablename --> m636 MYTABLENAME --> M637 638 omni_sql_ignorecase639< - Default: Current setting for 'ignorecase'640 - Valid settings are 0 or 1.641 - When entering a few letters before initiating completion, the list642 will be filtered to display only the entries which begin with the643 list of characters. When this option is set to 0, the list will be644 filtered using case sensitivity. >645 646 omni_sql_include_owner647< - Default: 0, unless dbext.vim 3.00 has been installed648 - Valid settings are 0 or 1.649 - When completing tables, procedure or views and using dbext.vim 3.00650 or higher the list of objects will also include the owner name.651 When completing these objects and omni_sql_include_owner is enabled652 the owner name will be replaced. >653 654 omni_sql_precache_syntax_groups655< - Default:656 ['syntax','sqlKeyword','sqlFunction','sqlOption','sqlType','sqlStatement']657 - sqlcomplete can be used in conjunction with other completion658 plugins. This is outlined at |sql-completion-filetypes|. When the659 filetype is changed temporarily to SQL, the sqlcompletion plugin660 will cache the syntax groups listed in the List specified in this661 option.662>663 6644.5 SQL Maps *sql-completion-maps*665------------666 667The default SQL maps have been described in other sections of this document in668greater detail. Here is a list of the maps with a brief description of each.669 670Static Maps671-----------672These are maps which use populate the completion list using Vim's syntax673highlighting rules. >674 <C-C>a675< - Displays all SQL syntax items. >676 <C-C>k677< - Displays all SQL syntax items defined as 'sqlKeyword'. >678 <C-C>f679< - Displays all SQL syntax items defined as 'sqlFunction. >680 <C-C>o681< - Displays all SQL syntax items defined as 'sqlOption'. >682 <C-C>T683< - Displays all SQL syntax items defined as 'sqlType'. >684 <C-C>s685< - Displays all SQL syntax items defined as 'sqlStatement'. >686 687Dynamic Maps688------------689These are maps which use populate the completion list using the dbext.vim690plugin. >691 <C-C>t692< - Displays a list of tables. >693 <C-C>p694< - Displays a list of procedures. >695 <C-C>v696< - Displays a list of views. >697 <C-C>c698< - Displays a list of columns for a specific table. >699 <C-C>l700< - Displays a comma-separated list of columns for a specific table. >701 <C-C>L702< - Displays a comma-separated list of columns for a specific table.703 This should only be used when the completion window is active. >704 <Right>705< - Displays a list of columns for the table currently highlighted in706 the completion window. <Right> is not recognized on most Unix707 systems, so this maps is only created on the Windows platform.708 If you would like the same feature on Unix, choose a different key709 and make the same map in your vimrc. >710 <Left>711< - Displays the list of tables.712 <Left> is not recognized on most Unix systems, so this maps is713 only created on the Windows platform. If you would like the same714 feature on Unix, choose a different key and make the same map in715 your vimrc. >716 <C-C>R717< - This maps removes all cached items and forces the SQL completion718 to regenerate the list of items.719 720Customizing Maps721----------------722You can create as many additional key maps as you like. Generally, the maps723will be specifying different syntax highlight groups.724 725If you do not wish the default maps created or the key choices do not work on726your platform (often a case on *nix) you define the following variable in727your |vimrc|: >728 let g:omni_sql_no_default_maps = 1729 730Do not edit ftplugin/sql.vim directly! If you change this file your changes731will be over written on future updates. Vim has a special directory structure732which allows you to make customizations without changing the files that are733included with the Vim distribution. If you wish to customize the maps734create an after/ftplugin/sql.vim (see |after-directory|) and place the same735maps from the ftplugin/sql.vim in it using your own key strokes. <C-C> was736chosen since it will work on both Windows and *nix platforms. On the windows737platform you can also use <C-Space> or ALT keys.738 739 7404.6 Using with other filetypes *sql-completion-filetypes*741------------------------------742 743Many times SQL can be used with different filetypes. For example Perl, Java,744PHP, Javascript can all interact with a database. Often you need both the SQL745completion and the completion capabilities for the current language you are746editing.747 748This can be enabled easily with the following steps (assuming a Perl file): >749 1. :e test.pl750 2. :set filetype=sql751 3. :set ft=perl752 753Step 1754------755Begins by editing a Perl file. Vim automatically sets the filetype to756"perl". By default, Vim runs the appropriate filetype file757ftplugin/perl.vim. If you are using the syntax completion plugin by following758the directions at |ft-syntax-omni| then the 'omnifunc' option has been set to759"syntax#Complete". Pressing <C-X><C-O> will display the omni popup containing760the syntax items for Perl.761 762Step 2763------764Manually setting the filetype to 'sql' will also fire the appropriate filetype765files ftplugin/sql.vim. This file will define a number of buffer specific766maps for SQL completion, see |sql-completion-maps|. Now these maps have767been created and the SQL completion plugin has been initialized. All SQL768syntax items have been cached in preparation. The SQL filetype script detects769we are attempting to use two different completion plugins. Since the SQL maps770begin with <C-C>, the maps will toggle the 'omnifunc' when in use. So you771can use <C-X><C-O> to continue using the completion for Perl (using the syntax772completion plugin) and <C-C> to use the SQL completion features.773 774Step 3775------776Setting the filetype back to Perl sets all the usual "perl" related items back777as they were.778 779 780vim:tw=78:ts=8:noet:ft=help:norl:781 